Azure Powershell Version Issue

Inderjit Singh

05 Jul, 2017 01:05 AM

I am using the new feature in Azure ARM Templates which allows multi-resource group deployment. To use this new feature we need to use the recent version of Azure Powershell released in June 2017. I am getting a misleading error.

ollowing is the error message I get -Hyak.Common.CloudException: InvalidTemplate: Deployment template validation failed: 'The template resource 'SaveEvenHubSendPolicyToKeyVault' at line '208' and column '10' is invalid. The api-version '2014-04-01-preview' used to deploy the template does not support 'ResourceGroup' property. Please use api-version '2017-05-10' or later to deploy the template. Please see https://aka.ms/arm-template/#resources for usage details.'.

I did update both the templates parent as well as nested template to use "2017-05-10" api version. I also logged onto Octopus Deploy sserver using Remote Desktop and ran the command from Powershell window. I was able to run the tempalte successfully from Powerhsell window but I keep on getting the above error message. My guess is that when I run the deployment through Octo Web interface it is not picking up the right version of Azure Powershell. but that's my theory. I have created a variable fro the porject with the name Octopus.Action.Azure.UseBundledAzurePowerShellModules and set the value to False but I am still getting the error.

I am running out of ideas now. Is this an Octo bug or am I missing something? Please make suggstions.
Thanks,
Inder

Just adding some more info to the issue.
Octopus.Action.Azure.UseBundledAzurePowerShellModules variable was added as a Project Variable. Also I added the following command to one of the project steps and can see the most recent version of Azure Powershell Module for Resource Manager Get-Module -ListAvailable -Name Azure*

Just want to write a update on how I implemented a workaround. I switched from using ARM Template Step to Azure Powershell step where I am using New-AzureRmResourceGroupDeployment command explicitly to run the ARM Template and that worked without any problems so at this point it looks like its an Octo Bug.

Unfortunately the Octopus.Action.Azure.UseBundledAzurePowerShellModules variable only applies to Octopus' Azure PowerShell steps and not the Azure Resource Group step (as this step uses the Microsoft Management .NET libraries and not PowerShell). We don't believe this is a bug in Octopus as such, but a limitation of the Azure Resource Group step (as this doesn't currenly use PowerShell).

We have created a GitHub issue here to investigate whether we can safely update to the latest version of these .NET libraries and whether this would fix the problem you're experiencing.

For now, your workaround of using the Azure PowerShell step to explicitly specify the New-AzureRmResourceGroupDeployment command is a good solution.

Today I realized that I made a mistake in my workaround of using New-AzureRmResourceGroupDeployment. I specified the incorrect ResourceGroup so that the EventHub was created in the same Resource Group as the KeyVault. Today when I tried creating the Eventhub in the different Resource Group then the KeyVault which is the requirement in my case I am getting failure. Following is the message, please suggest a solution.

Sorry, please ignore my previous comment. I was provisioning a new environment and did not have Octopus.Action.Azure.UseBundledAzurePowerShellModules variable in the variable set. Once, I added this variable the New-AzureRmResourceGroupDeployment command succeeded.
Thanks,

We agree with you. We have created a GitHub issue here to make sure this gets resolved.

As a workaround for the time being, you can install the latest version of the Azure PowerShell modules on your server and simply tell Octopus to use them instead (see this documentation for more details).

Can confirm getting schema errors on nested templates like @tim.poth even with latest modules and False flag variable (Octopus.Action.Azure.UseBundledAzurePowerShellModules)

Hyak.Common.CloudException: InvalidTemplate: Deployment template validation failed: 'The template resource 'StorageAccount' at line '61' and column '10' is invalid. The nested deployment has api-version '2017-08-01', which is not supported in api-version '2014-04-01-preview' used to deploy the template. Please use api-version '2017-05-10' or later to deploy the template. Or use an older api-version for the nested deployment in the template. Please see https://aka.ms/arm-template/#resources for usage details.'.

I get this exact same problem too - powershell modules are updated (5.1.1) , but no matter what API version is specified in either the deployment template or the nested templates, it is always trying to use the "2014-04-01-preview" api to deploy and thus erroring.

It even tells me to use the template that I've tried to use!

The nested deployment has api-version '2017-05-10', which is not supported in api-version '2014-04-01-preview' used to deploy the template. Please use api-version '2017-05-10' or later to deploy the template. Or use an older api-version for the nested deployment in the template. Please see https://aka.ms/arm-template/#resources for usage details.'.

I am also seeing this issue, and my understanding is that updating the PowerShell modules will have no impact on this, as the ARM template deployment step in Octopus is using the .net library to do this and not PowerShell, and that this library is 3-4 years old. Any idea when we can expect this to be updated?

Hi everyone, thanks for your feedback and patience on this. We're actively working on integrating the latest Azure .NET libraries to fix these problems and have plans to release these updates in April.