Skip to content

Commit

Permalink
Allow logging into specific subscription (Azure#18723)
Browse files Browse the repository at this point in the history
Resolves #1404

Co-authored-by: Heath Stewart <[email protected]>
  • Loading branch information
azure-sdk and heaths authored Feb 12, 2021
1 parent 044438e commit 7fb1931
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 6 additions & 5 deletions eng/common/TestResources/New-TestResources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ param (
[ValidateNotNullOrEmpty()]
[string] $TenantId,

[Parameter(ParameterSetName = 'Provisioner')]
# Azure SDK Developer Playground subscription
[Parameter()]
[ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')]
[string] $SubscriptionId,
[string] $SubscriptionId = 'faa080af-c1d8-40ad-9cce-e1a450ca5b57',

[Parameter(ParameterSetName = 'Provisioner', Mandatory = $true)]
[ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')]
Expand Down Expand Up @@ -141,8 +142,6 @@ try {
$root = [System.IO.Path]::Combine($repositoryRoot, "sdk", $ServiceDirectory) | Resolve-Path
$templateFileName = 'test-resources.json'
$templateFiles = @()
# Azure SDK Developer Playground
$defaultSubscription = "faa080af-c1d8-40ad-9cce-e1a450ca5b57"

Write-Verbose "Checking for '$templateFileName' files under '$root'"
Get-ChildItem -Path $root -Filter $templateFileName -Recurse | ForEach-Object {
Expand Down Expand Up @@ -202,7 +201,7 @@ try {
$context = Get-AzContext;
if (!$context) {
Log "You are not logged in; connecting to 'Azure SDK Developer Playground'"
$context = (Connect-AzAccount -Subscription $defaultSubscription).Context
$context = (Connect-AzAccount -Subscription $SubscriptionId).Context
}

# If no test application ID is specified during an interactive session, create a new service principal.
Expand Down Expand Up @@ -583,6 +582,8 @@ is passed to the ARM template as 'tenantId'.
Optional subscription ID to use for new resources when logging in as a
provisioner. You can also use Set-AzContext if not provisioning.
The default is the Azure SDK Developer Playground subscription ID.
.PARAMETER ProvisionerApplicationId
The AAD Application ID used to provision test resources when a provisioner is
specified.
Expand Down
4 changes: 3 additions & 1 deletion eng/common/TestResources/New-TestResources.ps1.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,16 @@ Optional subscription ID to use for new resources when logging in as a
provisioner.
You can also use Set-AzContext if not provisioning.
The default is the Azure SDK Developer Playground subscription ID.
```yaml
Type: String
Parameter Sets: Provisioner
Aliases:

Required: False
Position: Named
Default value: None
Default value: faa080af-c1d8-40ad-9cce-e1a450ca5b57
Accept pipeline input: False
Accept wildcard characters: False
```
Expand Down

0 comments on commit 7fb1931

Please sign in to comment.