"Run an Azure PowerShell Script" step failed

I created a simple azure powershell script step with a service principle account but it failed. I played with it several hour but i haven’t had any luck with it.

I run the following command in a powershell window without an error.

$creds = Get-Credential
Login-AzureRmAccount -Credential $creds -ServicePrincipal -Tenant "cxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx6"

Set-AzureWebsite -Name "$OctopusParameters['Azure.Api.Management.Hostname']" -HostNames @($OctopusParameters['Azure.Api.Management.Hostname'] + '.' + $OctopusParameters['Azure.Custom.DomainName'])

I attached the error log, step and account configuration screen; am i doing something wrong?


Step-Log.txt (3 KB)

Hi Kemal,

I think the problem here is that Set-AzureWebSite is a Service Management cmdlet, not a Resource Manager cmdlet. When you (or Octopus) calls Login-AzureRmAccount it logs in only for RM.

I suspect the reason it works for you in a PowerShell window is that you are authenticated as yourself for Service Management cmdlets in that context.

If you try using the RM equivalent: Set-AzureRMWebApp does that work for you?


Hi Michael,

Set-AzureRMWebApp worked without a problem.

Thanks for your help

That’s great to hear Kemal. Thanks for the update.

Happy Deployments!