Issue with Get-AzureRmWebApp

Hi again!

We’re trying to use Octopus Deploy for swapping slots in Azure Web Apps. Specifically, we’re trying to use Resource Manager to do this. To do so, we first make a call to Get-AzureRmWebApp to get a list of all our webapps and their respective Resource Groups.

When I make the call to Get-AzureRmWebApp by itself in one of our servers, I get the list of the webapps and each of the objects returned has a “ResourceGroup” key which contains the resource group to which that particular web app belongs. However, when I run exactly the same code within the context of Octopus Deploy (using a Service Principal Azure account in OD), even though I get a reply with many other properties of the webapps, it does not have the ResourceGroup property.

I’ve made sure that all our deploy tentacles are using the latest version of the Azure PowerShell SDK (1.6.0) and I’ve set the “Octopus.Action.Azure.UseBundledAzurePowerShellModules” variable to False, but still, this discrepancy in behavior continues.

Have any of you seen this before? It’s really annoying because all the Rm commands require the ResourceGroup and if we cannot dynamically obtain it via Get-AzureRmWebApp then we have to hardcode it (or parse it from the Id field, which is what I’m doing now and isn’t very efficient or clean).

Any ideas?

Thanks in advance!
Tiago

Hey Tiago,

The Azure deployment steps execute from the Octopus Server, rather than a Tentacle.

Have you tried installing the latest Azure PowerShell modules on the Octopus Server?

Regards,
Michael

Hi Michael,

Yep, the server also has the latest Azure PowerShell modules. In fact, within the same script that I was trying to run, I printed the current Azure version with Get-Module -ListAvailable -Name Azure -Refresh and it showed version 1.6.0.

The only difference I can imagine (and even then I’m still dumbfounded as to why it happens) is that when I run the commands directly on a PowerShell I first manually add an Azure RM account by doing Add-AzureRmAccount and then login with my credentials (this command creates a GUI popup to login with email and password). When using Octopus Deploy I have the Service Principal account configured directly in OD. Another thing that I’ve tried, in order to try and figure out whether it’s a permissions issue, was to basically give all permissions to the Service Principal account but even then, no dice. I would be really surprised if it is a permissions issue, as the resource group information is also present in the Id field which is in the return message that I get on OD.

Really weird stuff…

Cheers,
Tiago

Hi Tiago,

I replicated your observations. That is rather strange. It may be worth lodging a query with the Azure PowerShell team.

Interestingly, when I look at the documentation for the Get-AzureRmWebApp cmdlet, it doesn’t list an empty Parameter Set. It seems to want at least a Resource Group. Maybe you are better to iterate over the Resource Groups, and then the Web Apps within each Resource Group?

I wish I had a better answer for you.

Regards,
Michael

Hi Michael,

Very strange indeed… and it gets stranger. When I run the exact same command within a PowerShell workflow within OD, then… the ResourceGroup is returned! So weird!

Anyway, at least now it’s documented here :slight_smile: in case someone runs into the same issue.

Thanks for the input!

Regards,
Tiago

Notice:

This issue has been closed due to inactivity. If you encounter the same or a similar issue and require help, please open a new discussion (if we asked for logs or extra details in this thread, consider including them in the new thread). If you are the creator of this thread and believe it should not be closed let us know via our support email.