In my previous post I showed you how we can export Azure resource groups into ARM templates using the Azure Portal. For those of us who are not GUI fans (including myself) Azure PowerShell and Azure CLI provide cmdlets/commands to leverage the export feature for cloning, redeploying and automating Azure resource group deployments.
With the latest Azure PowerShell you can execute below cmdlet to export a running resource group to an ARM template.
Export-AzureRmResourceGroup -ResourceGroupName <RG name> -Path <template path>
To export resource groups from a previous deployment you may use the below cmdlet syntax.
Save-AzureRmResourceGroupDeploymentTemplate -DeploymentName <Deployment Name> -ResourceGroupName <RG Name>-Path <template path>
You can use the following syntax to export a running resource group to an ARM template.
azure group export <name> [template path]
Use below command syntax to export to an ARM template from a previously deployed Resource Group
group deployment template download [options] <resource-group> <name> [directory]
Last week I was deploying a new Azure Stack POC deployment with my friend CDM MVP Nirmal Thewarathanthri. While we were working on the SQL RP deployment there was a strange issue. The problem was every time when the SqlRPTemplateDeployment.ps1 was executed, it always failed with below error.
New-AzureRmResourceGroupDeployment : InvalidApiVersionParameter: The api-version ‘2015-11-01’ is invalid. The supported versions
At D:\SQLRP\AzureStack.SqlRP.Deployment.220.127.116.11\Content\Deployment\SqlRPTemplateDeployment.ps1:207 char:5
+ New-AzureRmResourceGroupDeployment -Name “newSqlRPTemplateDeploym …
Wrong Azure PowereShell version
The Azure Stack documentation instructs us to update to the latest version of AzurePowerShell in the Client VM before deploying the SQL RP. But the latest version 1.2.2 released in March seems not supported in this scenario. When we downgraded that to version 1.2.1 (February version) we were able to continue with the SQL RP deployment.
If you are using the web installer for Azure PowerShell be mindful to avoid that at least for now. You can explore all the releases from GitHub and download them as MSI packages.
“Save Our Souls” is the International distress call for help in maritime operations. Over the years SOS has become more common term to imply a call for help in a disastrous situation. In Microsoft Azure sometime you may have faced such situations especially with IaaS VMs. For an example RDP not working in a Windows VM or SSH ceased to function in a Linux VM. When all hope is lost you may contact Azure Support or try to restart the VM (from Azure Portal) or resize the VM as a last resort.
Now going into all of the above troubles is no longer required to rescue your Azure IaaS VMs. The latest Microsoft Azure PowerShell cmdlet improvements allows you to redeploy your virtual machine when you invoke a redeploy operation through Azure PowerShell.
- Below cmdlet works only with Azure Resource Manager based VMs.
- Latest version of Azure PowerShell needs to be installed in the management PC from which you are invoking the redeploy operation.
- Dynamic IP addresses will be changed after completing the redeploy operation.
- Data on local disks (ephemeral storage) will be lost.
Following is the syntax for the updated Set-AzureRmVM cmdlet. Note that the -Redeploy switch is used to invoke a redeploy operation.
Set–AzureRmVM –Redeploy –ResourceGroupName $rgname –Name $vmname
The VM status changes from Running > Updating > Starting > Running during the operation. The final Running status means that VM has been successfully redeployed.
For a complete reference of the Set-AzureRmVM cmdlet please refer here.