How to check version of Azure PowerShell and Azure SDK

Usually Azure DevOps need check version of Azure PowerShell and Azure SDK,that is to ensure the required PowerShell commands and Azure API are packaged there, here below are quick ways to go:

  • Check version of Azure PowerShell

launch Azure PowerShell as admin, then run commands below:

$name=’Azure’

if(Get-Module -ListAvailable |
Where-Object { $_.name -eq $name })
{
(Get-Module -ListAvailable | Where-Object{ $_.Name -eq $name }) |
Select Version, Name, Author, PowerShellVersion  | Format-List;
}
else
{
“The Azure PowerShell module is not installed.”
}

also the commands can be saved into a PowerShell file like Get-AzurePowerShellCmdletsVersion.ps1, then executing the PowerShell file will result the same as above.

here is output:

ps1

  • Check version of Azure SDK

Checking Azure SDK version can be done by any of :

Azure PowerShell: Get-AzureDeployment -ServiceName **** -Slot Production | Where-Object -Property SdkVersion | select SdkVersion

VM environment: RoleModel.xml, Role initialization log of the deployment or SDK installation output. See more: http://blogs.msdn.com/b/kwill/archive/2011/05/05/windows-azure-role-architecture.aspx

Programming: put the codes in web role or worker role

public string GetWindowsAzureSDKVersion()
{
try
{
// Warning this is undocumented and could break in a future SDK release
string roleModelFile = Environment.GetEnvironmentVariable(“RoleRoot”) + “\\RoleModel.xml”;
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(roleModelFile);

return xmlDocument.GetElementsByTagName(“RoleModel”)[0].Attributes[“version”].Value;
}
catch (Exception e)
{
return “unknown”;
}
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *