Merge pull request #26 from AbelHu/master

On behalf of Jianbin: Support Azure PowerShell after version 0.8.8.
This commit is contained in:
Long Li 2014-10-31 15:57:20 -07:00
Родитель 3f96d1b521 739fbf177f
Коммит 19f9ccc13a
1 изменённых файлов: 30 добавлений и 5 удалений

Просмотреть файл

@ -231,11 +231,36 @@ Function InstallPackages ($VMIpAddress, $VMSshPort, $VMUserName, $VMPassword)
return $retValue
}
Function SetSubscription ($subscriptionID, $subscriptionName, $certificateThumbprint, $managementEndpoint, $storageAccount)
Function IsEnvironmentSupported()
{
$version = (Get-Module -Name "Azure").Version
If ($version.Major -GT 0 -OR
$version.Minor -GT 8 -OR
(($version.Minor -EQ 8) -And ($version.Build -GE 8)))
{
return $true
}
Else
{
return $false
}
}
Function SetSubscription ($subscriptionID, $subscriptionName, $certificateThumbprint, $managementEndpoint, $storageAccount, $environment = "AzureCloud")
{
$myCert = Get-Item cert:\CurrentUser\My\$certificateThumbprint
Set-AzureSubscription -SubscriptionName $subscriptionName -Certificate $myCert -SubscriptionID $subscriptionID -ServiceEndpoint $managementEndpoint
Set-AzureSubscription -SubscriptionName $subscriptionName -CurrentStorageAccountName $storageAccount
# For Azure Powershell Version >= 0.8.8, Environment is used in Set-AzureSubscription for replacing ManagementEndpoint
if (IsEnvironmentSupported)
{
Set-AzureSubscription -SubscriptionName $subscriptionName -Certificate $myCert -SubscriptionID $subscriptionID `
-CurrentStorageAccountName $storageAccount -Environment $environment
}
Else
{
Set-AzureSubscription -SubscriptionName $subscriptionName -Certificate $myCert -SubscriptionID $subscriptionID `
-CurrentStorageAccountName $storageAccount -ServiceEndpoint $managementEndpoint
}
Select-AzureSubscription -Current $subscriptionName
}