diff --git a/Common/PowerShell3/VstsAzureHelpers/InitializeFunctions.ps1 b/Common/PowerShell3/VstsAzureHelpers/InitializeFunctions.ps1 index 4866ed4..9132f3f 100644 --- a/Common/PowerShell3/VstsAzureHelpers/InitializeFunctions.ps1 +++ b/Common/PowerShell3/VstsAzureHelpers/InitializeFunctions.ps1 @@ -37,7 +37,9 @@ function Initialize-AzureSubscription { [Parameter(Mandatory=$true)] $Endpoint, [Parameter(Mandatory=$false)] - [string]$StorageAccount) + [string]$StorageAccount), + [Parameter(Mandatory=$true)] + $environment #Set UserAgent for Azure Calls Set-UserAgent @@ -57,7 +59,12 @@ function Initialize-AzureSubscription { $additional['CurrentStorageAccountName'] = $StorageAccount } - $environmentName = "AzureCloud" + if( $environment) { + $environmentName = $environment + } + else { + $environmentName = "AzureCloud" + } if( $Endpoint.Data.Environment ) { $environmentName = $Endpoint.Data.Environment } @@ -87,7 +94,7 @@ function Initialize-AzureSubscription { if ($script:azureRMProfileModule) { try { Write-Host "##[command]Add-AzureRMAccount -Credential $psCredential" - $null = Add-AzureRMAccount -Credential $psCredential + $null = Add-AzureRMAccount -Credential $psCredential -Environment $environmentName } catch { # Provide an additional, custom, credentials-related error message. Write-VstsTaskError -Message $_.Exception.Message diff --git a/Common/PowerShell3/VstsAzureHelpers/VstsAzureHelpers.psm1 b/Common/PowerShell3/VstsAzureHelpers/VstsAzureHelpers.psm1 index 281c6a6..c00fd97 100644 --- a/Common/PowerShell3/VstsAzureHelpers/VstsAzureHelpers.psm1 +++ b/Common/PowerShell3/VstsAzureHelpers/VstsAzureHelpers.psm1 @@ -32,7 +32,8 @@ function Initialize-Azure { $endpoint = Get-VstsEndpoint -Name $serviceName -Require $storageAccount = Get-VstsInput -Name StorageAccount - + $environment = Get-VstsInput -Name AzureEnvironment + # Determine which modules are preferred. $preferredModules = @( ) if ($endpoint.Auth.Scheme -eq 'ServicePrincipal') { @@ -46,7 +47,7 @@ function Initialize-Azure { # Import/initialize the Azure module. Import-AzureModule -PreferredModule $preferredModules - Initialize-AzureSubscription -Endpoint $endpoint -StorageAccount $storageAccount + Initialize-AzureSubscription -Endpoint $endpoint -StorageAccount $storageAccount -environment $environment # Check the installed Azure Powershell version $currentVersion = (Get-Module -Name AzureRM.profile).Version diff --git a/Tasks/ExecuteSql/task.json b/Tasks/ExecuteSql/task.json index 30611ec..7d8f6a7 100644 --- a/Tasks/ExecuteSql/task.json +++ b/Tasks/ExecuteSql/task.json @@ -186,6 +186,15 @@ "groupName": "firewall", "defaultValue": "true", "helpMarkDown": "If selected, then after the task ends, the IP Addresses specified here are deleted from the 'Allowed IP Addresses' list of the Azure SQL Server's Firewall." + }, + { + "name": "AzureEnvironment", + "type": "string", + "label": "Azure Cloud Environment", + "required": false, + "groupName": "target", + "defaultValue": "", + "helpMarkDown": "Azure Cloud Environment name i.e AzureCloud, AzureChinaCloud etc." } ], "sourceDefinitions": [