Skip to content

addition Azure Cloud Environment input #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions Common/PowerShell3/VstsAzureHelpers/InitializeFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions Common/PowerShell3/VstsAzureHelpers/VstsAzureHelpers.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions Tasks/ExecuteSql/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down