Added support for Azure Powershell v3

This commit is contained in:
Shital Savekar 2016-10-12 01:09:10 -07:00
Родитель 786d1212bb
Коммит 5ed7af8d3f
6 изменённых файлов: 27 добавлений и 27 удалений

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

@ -5,8 +5,8 @@
{
if ( $UseAzureResourceManager )
{
LogMsg "Verifying $ExtensionName from Azure Using Get-AzureResource command ..."
$ExtensionStatus = Get-AzureResource -OutputObjectFormat New -ResourceGroupName $ResourceGroupName -ResourceType "Microsoft.Compute/virtualMachines/extensions" -ExpandProperties
LogMsg "Verifying $ExtensionName from Azure Using Get-AzureRmResource command ..."
$ExtensionStatus = Get-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType "Microsoft.Compute/virtualMachines/extensions" -ExpandProperties
if ( ($ExtensionStatus.Properties.ProvisioningState -eq "Succeeded") -and ( $ExtensionStatus.Properties.Type -eq $ExtensionName ) )
{
LogMsg "$ExtensionName extension status is Succeeded in Properties.ProvisioningState"
@ -180,27 +180,27 @@ Function SetAzureVMExtension ( $publicConfigString, $privateConfigString, $Exten
{
$RGName = $vmData.ResourceGroupName
$VMName = $vmData.RoleName
$Location = (Get-AzureResourceGroup -Name $RGName).Location
$Location = (Get-AzureRmResourceGroup -Name $RGName).Location
if ( $publicConfigString -and $privateConfigString )
{
LogMsg "Public Config : $publicConfigString"
LogMsg "Private Config : $privateConfigString"
$ExtStatus = Set-AzureVMExtension -ResourceGroupName $RGName -VMName $VMName -Location $Location -Name $ExtensionName -Publisher $Publisher -ExtensionType $ExtensionName -TypeHandlerVersion $LatestExtensionVersion -Settingstring $publicConfigString -ProtectedSettingString $privateConfigString -Verbose
$ExtStatus = Set-AzureRmVMExtension -ResourceGroupName $RGName -VMName $VMName -Location $Location -Name $ExtensionName -Publisher $Publisher -ExtensionType $ExtensionName -TypeHandlerVersion $LatestExtensionVersion -Settingstring $publicConfigString -ProtectedSettingString $privateConfigString -Verbose
}
else
{
if ($publicConfigString)
{
LogMsg "Public Config : $publicConfigString"
$ExtStatus = Set-AzureVMExtension -ResourceGroupName $RGName -VMName $VMName -Location $Location -Name $ExtensionName -Publisher $Publisher -ExtensionType $ExtensionName -TypeHandlerVersion $LatestExtensionVersion -Settingstring $publicConfigString -Verbose
$ExtStatus = Set-AzureRmVMExtension -ResourceGroupName $RGName -VMName $VMName -Location $Location -Name $ExtensionName -Publisher $Publisher -ExtensionType $ExtensionName -TypeHandlerVersion $LatestExtensionVersion -Settingstring $publicConfigString -Verbose
}
if ($privateConfigString )
{
LogMsg "Private Config : $privateConfigString"
$ExtStatus = Set-AzureVMExtension -ResourceGroupName $RGName -VMName $VMName -Location $Location -Name $ExtensionName -Publisher $Publisher -ExtensionType $ExtensionName -TypeHandlerVersion $LatestExtensionVersion -ProtectedSettingString $privateConfigString -Verbose
$ExtStatus = Set-AzureRmVMExtension -ResourceGroupName $RGName -VMName $VMName -Location $Location -Name $ExtensionName -Publisher $Publisher -ExtensionType $ExtensionName -TypeHandlerVersion $LatestExtensionVersion -ProtectedSettingString $privateConfigString -Verbose
}
}
if ( $ExtStatus.Status -eq "Succeeded" )
if ( ![string]::IsNullOrEmpty($ExtStatus.StatusCode) -and $ExtStatus.StatusCode.ToString() -eq "OK" )
{
$retValue = $true
$waitForExtension = $false

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

@ -1221,7 +1221,7 @@ Function GetAndCheckKernelLogs($allDeployedVMs, $status, $vmUser, $vmPassword)
if ( $UseAzureResourceManager )
{
LogMsg "Adding preserve tag to $($VM.ResourceGroup) .."
$out = Set-AzureResourceGroup -Name $($VM.ResourceGroup) -Tag @{Name =$preserveKeyword; Value = "yes"},@{Name ="callTrace"; Value = "yes"}
$out = Set-AzureRmResourceGroup -Name $($VM.ResourceGroup) -Tag @{Name =$preserveKeyword; Value = "yes"},@{Name ="callTrace"; Value = "yes"}
}
else
{
@ -2670,7 +2670,7 @@ Function DoTestCleanUp($result, $testName, $DeployedServices, $ResourceGroups, [
}
else
{
$RGdetails = Get-AzureResourceGroup -Name $group
$RGdetails = Get-AzureRmResourceGroup -Name $group
if ( ( $RGdetails.Tags[0].Name -eq $preserveKeyword ) -and ( $RGdetails.Tags[0].Value -eq "yes" ))
{
LogMsg "Skipping Cleanup of preserved resource group."
@ -2707,7 +2707,7 @@ Function DoTestCleanUp($result, $testName, $DeployedServices, $ResourceGroups, [
{
LogMsg "Preserving the Resource Group(s) $group"
LogMsg "Setting tags : preserve = yes; testName = $testName"
$out = Set-AzureResourceGroup -Name $group -Tag @{Name =$preserveKeyword; Value = "yes"},@{Name ="testName"; Value = "$testName"}
$out = Set-AzureRmResourceGroup -Name $group -Tag @{Name =$preserveKeyword; Value = "yes"},@{Name ="testName"; Value = "$testName"}
LogMsg "Collecting VM logs.."
if ( !$isVMLogsCollected)
{
@ -4414,8 +4414,8 @@ Function Get-SSHDetailofVMs($DeployedServices, $ResourceGroups)
{
foreach ($ResourceGroup in $ResourceGroups.Split("^"))
{
$RGIPdata = Get-AzureResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Network/publicIPAddresses" -ExpandProperties -OutputObjectFormat New -Verbose
$RGVMs = Get-AzureResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Compute/virtualMachines" -ExpandProperties -OutputObjectFormat New -Verbose
$RGIPdata = Get-AzureRmResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Network/publicIPAddresses" -ExpandProperties -Verbose
$RGVMs = Get-AzureRmResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Compute/virtualMachines" -ExpandProperties -Verbose
foreach ($testVM in $RGVMs)
{
$AllEndpoints = $testVM.Properties.NetworkProfile.InputEndpoints
@ -4461,9 +4461,9 @@ Function GetAllDeployementData($DeployedServices, $ResourceGroups)
foreach ($ResourceGroup in $ResourceGroups.Split("^"))
{
LogMsg "Collecting $ResourceGroup data.."
$RGIPdata = Get-AzureResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Network/publicIPAddresses" -Verbose -ExpandProperties -OutputObjectFormat New
$RGVMs = Get-AzureResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Compute/virtualMachines" -Verbose -ExpandProperties -OutputObjectFormat New
$NICdata = Get-AzureResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Network/networkInterfaces" -Verbose -ExpandProperties -OutputObjectFormat New
$RGIPdata = Get-AzureRmResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Network/publicIPAddresses" -Verbose -ExpandProperties
$RGVMs = Get-AzureRmResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Compute/virtualMachines" -Verbose -ExpandProperties
$NICdata = Get-AzureRmResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Network/networkInterfaces" -Verbose -ExpandProperties
$numberOfVMs = 0
foreach ($testVM in $RGVMs)
{
@ -4471,7 +4471,7 @@ Function GetAllDeployementData($DeployedServices, $ResourceGroups)
}
if ( $numberOfVMs -gt 1 )
{
$LBdata = Get-AzureResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Network/loadBalancers" -ExpandProperties -OutputObjectFormat New -Verbose
$LBdata = Get-AzureRmResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Network/loadBalancers" -ExpandProperties -Verbose
}
foreach ($testVM in $RGVMs)
{
@ -4924,7 +4924,7 @@ Function RestartAllDeployments($allVMData)
{
if ( $UseAzureResourceManager)
{
$restartVM = Restart-AzureVM -ResourceGroupName $vmData.ResourceGroupName -Name $vmData.RoleName -Verbose
$restartVM = Restart-AzureRmVM -ResourceGroupName $vmData.ResourceGroupName -Name $vmData.RoleName -Verbose
if ( $restartVM.Status -eq "Succeeded" )
{
LogMsg "Restarted : $($vmData.RoleName)"
@ -6665,13 +6665,13 @@ Function GetStorageAccountKey ($xmlConfig)
if ( $UseAzureResourceManager )
{
$storageAccountName = $xmlConfig.config.Azure.General.ARMStorageAccount
$StorageAccounts = Get-AzureStorageAccount
$StorageAccounts = Get-AzureRmStorageAccount
foreach ($SA in $StorageAccounts)
{
if ( $SA.Name -eq $storageAccountName )
if ( $SA.StorageAccountName -eq $storageAccountName )
{
LogMsg "Getting $storageAccountName storage account key..."
$storageAccountKey = (Get-AzureStorageAccountKey -ResourceGroupName $SA.ResourceGroupName -Name $SA.Name).Key1
$storageAccountKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $SA.ResourceGroupName -Name $SA.StorageAccountName).Value[0]
}
}
}

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

@ -16,7 +16,7 @@ if ($isDeployed)
LogMsg "Trying to restart $($AllVMData.RoleName)..."
if ( $UseAzureResourceManager )
{
$restartVM = Restart-AzureVM -ResourceGroupName $AllVMData.ResourceGroupName -Name $AllVMData.RoleName -Verbose
$restartVM = Restart-AzureRmVM -ResourceGroupName $AllVMData.ResourceGroupName -Name $AllVMData.RoleName -Verbose
if ( $restartVM.Status -eq "Succeeded" )
{
$isSSHOpened = isAllSSHPortsEnabledRG -AllVMDataObject $AllVMData
@ -33,7 +33,7 @@ if ($isDeployed)
else
{
$isRestarted = $false
LogErr "Restart Failed. Operation ID : $($restartVM.TrackingOperationId)"
LogErr "Restart Failed. Operation ID : $($restartVM.OperationId)"
}
}
else

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

@ -16,7 +16,7 @@ if ($isDeployed)
LogMsg "Trying to shut down $($AllVMData.RoleName)..."
if ( $UseAzureResourceManager )
{
$stopVM = Stop-AzureVM -ResourceGroupName $AllVMData.ResourceGroupName -Name $AllVMData.RoleName -Force -StayProvisioned -Verbose
$stopVM = Stop-AzureRmVM -ResourceGroupName $AllVMData.ResourceGroupName -Name $AllVMData.RoleName -Force -StayProvisioned -Verbose
if ( $stopVM.Status -eq "Succeeded" )
{
$isStopped = $true

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

@ -17,10 +17,10 @@ else
if ( $UseAzureResourceManager )
{
$StorAccount = $xmlConfig.config.Azure.General.ARMStorageAccount
$AccountDetail = Get-AzureStorageAccount | where {$_.Name -eq $StorAccount}
$AccountDetail = Get-AzureRmStorageAccount | where {$_.StorageAccountName -eq $StorAccount}
$Location = $AccountDetail.PrimaryLocation
$AccountType = $AccountDetail.AccountType
$SupportSizes = (Get-AzureVMSize -Location $location).Name
$AccountType = $AccountDetail.Sku.Tier.ToString()
$SupportSizes = (Get-AzureRmVMSize -Location $location).Name
}
else
{

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

@ -51,7 +51,7 @@ if ($isDeployed)
if ($LogFilesPaths)
{
$retryCount = 1
$maxRetryCount = 50
$maxRetryCount = 20
do
{ LogMsg "Attempt : $retryCount/$maxRetryCount : Checking extension log files...."
foreach ($file in $LogFilesPaths.Split(","))