diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index ea2987f115e..64e075c5704 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -52,7 +52,7 @@ param ( [ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')] [string] $ProvisionerApplicationOid, - [Parameter(ParameterSetName = 'Provisioner', Mandatory = $true)] + [Parameter(ParameterSetName = 'Provisioner')] [string] $ProvisionerApplicationSecret, [Parameter()] diff --git a/eng/common/TestResources/New-TestResources.ps1.md b/eng/common/TestResources/New-TestResources.ps1.md index 55f791ea1a6..f44feb1ab43 100644 --- a/eng/common/TestResources/New-TestResources.ps1.md +++ b/eng/common/TestResources/New-TestResources.ps1.md @@ -29,7 +29,7 @@ New-TestResources.ps1 [-BaseName ] [-ResourceGroupName ] [-Servi [-TestResourcesDirectory ] [-TestApplicationId ] [-TestApplicationSecret ] [-TestApplicationOid ] -TenantId [-SubscriptionId ] -ProvisionerApplicationId [-ProvisionerApplicationOid ] - -ProvisionerApplicationSecret [-DeleteAfterHours ] [-Location ] + [-ProvisionerApplicationSecret ] [-DeleteAfterHours ] [-Location ] [-Environment ] [-ResourceType ] [-ArmTemplateParameters ] [-AdditionalParameters ] [-EnvironmentVariables ] [-CI] [-Force] [-OutFile] [-SuppressVsoCommands] [-ServicePrincipalAuth] [-NewTestResourcesRemainingArguments ] @@ -426,7 +426,7 @@ Type: String Parameter Sets: Provisioner Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/eng/common/TestResources/Remove-TestResources.ps1 b/eng/common/TestResources/Remove-TestResources.ps1 index 4d28acc7d09..490b41b8ebe 100644 --- a/eng/common/TestResources/Remove-TestResources.ps1 +++ b/eng/common/TestResources/Remove-TestResources.ps1 @@ -34,8 +34,8 @@ param ( [ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')] [string] $ProvisionerApplicationId, - [Parameter(ParameterSetName = 'Default+Provisioner', Mandatory = $true)] - [Parameter(ParameterSetName = 'ResourceGroup+Provisioner', Mandatory = $true)] + [Parameter(ParameterSetName = 'Default+Provisioner')] + [Parameter(ParameterSetName = 'ResourceGroup+Provisioner')] [string] $ProvisionerApplicationSecret, [Parameter(ParameterSetName = 'Default', Position = 0)] diff --git a/eng/common/TestResources/Remove-TestResources.ps1.md b/eng/common/TestResources/Remove-TestResources.ps1.md index 15ac14ea87e..62b9e4f987b 100644 --- a/eng/common/TestResources/Remove-TestResources.ps1.md +++ b/eng/common/TestResources/Remove-TestResources.ps1.md @@ -23,7 +23,7 @@ Remove-TestResources.ps1 [-BaseName ] [-SubscriptionId ] [[-Serv ### Default+Provisioner ``` Remove-TestResources.ps1 -BaseName -TenantId [-SubscriptionId ] - -ProvisionerApplicationId -ProvisionerApplicationSecret [[-ServiceDirectory] ] + -ProvisionerApplicationId [-ProvisionerApplicationSecret ] [[-ServiceDirectory] ] [-Environment ] [-ResourceType ] [-ServicePrincipalAuth] [-Force] [-RemoveTestResourcesRemainingArguments ] [-ProgressAction ] [-WhatIf] [-Confirm] [] @@ -32,7 +32,7 @@ Remove-TestResources.ps1 -BaseName -TenantId [-SubscriptionId ### ResourceGroup+Provisioner ``` Remove-TestResources.ps1 [-ResourceGroupName ] -TenantId [-SubscriptionId ] - -ProvisionerApplicationId -ProvisionerApplicationSecret [[-ServiceDirectory] ] + -ProvisionerApplicationId [-ProvisionerApplicationSecret ] [[-ServiceDirectory] ] [-Environment ] [-CI] [-ResourceType ] [-ServicePrincipalAuth] [-Force] [-RemoveTestResourcesRemainingArguments ] [-ProgressAction ] [-WhatIf] [-Confirm] [] @@ -184,7 +184,7 @@ Type: String Parameter Sets: Default+Provisioner, ResourceGroup+Provisioner Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False diff --git a/eng/common/TestResources/deploy-test-resources.yml b/eng/common/TestResources/deploy-test-resources.yml index 5b1b080979a..b4197dc236d 100644 --- a/eng/common/TestResources/deploy-test-resources.yml +++ b/eng/common/TestResources/deploy-test-resources.yml @@ -7,6 +7,7 @@ parameters: ServiceConnection: not-specified ResourceType: test UseFederatedAuth: false + SubscriptionConfigurationFilePath: '' # SubscriptionConfiguration will be splatted into the parameters of the test @@ -54,9 +55,17 @@ steps: Inline: | eng/common/scripts/Import-AzModules.ps1 - $subscriptionConfiguration = @' - ${{ parameters.SubscriptionConfiguration }} + if ('${{ parameters.SubscriptionConfigurationFilePath }}' -ne '') { + $subscriptionConfiguration = ` + Get-Content '${{ parameters.SubscriptionConfigurationFilePath }}' ` + | ConvertFrom-Json -AsHashtable; + } else { + # Multiline string termination ('@) needs to be at the beginning + # of the line + $subscriptionConfiguration = @' + ${{ parameters.SubscriptionConfiguration }} '@ | ConvertFrom-Json -AsHashtable; + } # The subscriptionConfiguration may have ArmTemplateParameters defined, so # pass those in via the ArmTemplateParameters flag, and handle any diff --git a/eng/common/TestResources/remove-test-resources.yml b/eng/common/TestResources/remove-test-resources.yml index 121f6b3dda4..89aa7d825e4 100644 --- a/eng/common/TestResources/remove-test-resources.yml +++ b/eng/common/TestResources/remove-test-resources.yml @@ -7,6 +7,7 @@ parameters: ServiceConnection: not-specified ResourceType: test UseFederatedAuth: false + SubscriptionConfigurationFilePath: '' # SubscriptionConfiguration will be splat into the parameters of the test # resources script. It should be JSON in the form: @@ -36,10 +37,20 @@ steps: Inline: | eng/common/scripts/Import-AzModules.ps1 - $subscriptionConfiguration = @" - ${{ parameters.SubscriptionConfiguration }} + + if ('${{ parameters.SubscriptionConfigurationFilePath }}' -ne '') { + $subscriptionConfiguration = ` + Get-Content '${{ parameters.SubscriptionConfigurationFilePath }}' ` + | ConvertFrom-Json -AsHashtable; + } else { + # Multiline string termination ("@) needs to be at the beginning + # of the line + $subscriptionConfiguration = @" + ${{ parameters.SubscriptionConfiguration }} "@ | ConvertFrom-Json -AsHashtable; + } + eng/common/TestResources/Remove-TestResources.ps1 ` @subscriptionConfiguration ` -ResourceType '${{ parameters.ResourceType }}' ` diff --git a/eng/common/TestResources/sub-config/AzurePublicMsft.json b/eng/common/TestResources/sub-config/AzurePublicMsft.json new file mode 100644 index 00000000000..78d8a782c26 --- /dev/null +++ b/eng/common/TestResources/sub-config/AzurePublicMsft.json @@ -0,0 +1,10 @@ +{ + "SubscriptionId": "2cd617ea-1866-46b1-90e3-fffb087ebf9b", + "TenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "TestApplicationId": "f850650c-1fcf-4489-b46f-71af2e30d360", + "TestApplicationOid": "30511c9d-ba1a-4c7b-b422-5b543da11b3f", + "ProvisionerApplicationId": "f850650c-1fcf-4489-b46f-71af2e30d360", + "ProvisionerApplicationOid": "30511c9d-ba1a-4c7b-b422-5b543da11b3f", + "Environment": "AzureCloud", + "AzureSubscription": "Azure SDK Test Resources" +} \ No newline at end of file