Azure Web App Target Creation Failed


We are trying to create Web App Targets dynamically in Octopus Deploy using New-OctopusAzureWebAppTarget powershell command.

Following is the sample script we are trying to run.

New-OctopusAzureWebAppTarget -name “dev-test-cd” -azureWebApp 'test-cd'
-azureResourceGroupName ‘myresourcegroup’ -octopusAccountIdOrName 'my azure subscription name with spaces'
-octopusRoles ‘CD’ `

We are running this script via an Azure Powershell step and the step runs on octopus deploy server.

The script fails with the following message.

Account with Id / Name, my azure subscription name with spaces, not found.

Error running AzureWebAppCreateTargetServiceMessageHandler for create-azurewebapptarget: Account with Id / Name, my azure subscription name with spaces, not found.

System.Exception: Account with Id / Name, my azure subscription name with spaces, not found.

at Octopus.Server.Orchestration.ServerTasks.Deploy.ActionDispatch.ServiceMessageHandlers.AzureWebAppCreateTargetServiceMessageHandler.BuildAzureWebAppEndpoint(ScriptOutputAction action, VariableDictionary variables)

at Octopus.Server.Orchestration.Targets.Scripting.ServiceMessageHandlerCreateTargetBase.CreateOrUpdateTarget(ScriptOutputAction action, VariableDictionary variableDictionary)

at Octopus.Server.Orchestration.ServerTasks.Deploy.ActionDispatch.ServiceMessageHandlers.AzureWebAppCreateTargetServiceMessageHandler.HandleServiceMessage(ScriptOutputAction action, VariableCollection variables, ITaskContext taskContext, ActionCommand command)

at Octopus.Server.Orchestration.ServerTasks.Deploy.ActionDispatch.ServiceMessageHandlers.ServiceMessageProcessor.ExecuteHandlersForAction(ILog log, VariableCollection variables, ScriptOutputAction action, ActionCommand command)

Octopus.Server version 2018.11.3 (2018.11.3+Branch.tags-2018.11.3.Sha.b3219050e8151203eeb7e6976f1615c9b2d375c1)

Please note I have replace the real subscription name with ‘my azure subscription name with spaces’

We have also tried passing subscription id to the command instead, but got the similar error result.

On a related note, we have managed to execute the above script successfully on a different Azure subscription (with corresponding subscription related command arguments of course). So it appears the issue is related to current subscription. However we could not find the root of the issue.

Do you know under which condition(s) Octopus Azure Powershell step returns above error? Which might point us in the right direction to diagnose the issue.


Hi Mahesh,

Thank you for reaching out. The -octopusAccountIdOrName refers to the account in Octopus tied to the MSDN subscription. Please make sure your subscription “My Azure Subscription Name with spaces” is tied to an account in Octopus. In this screenshot I would use “Azure MSDN Account”, “Bob MSDN Account” or “Octopus Azure Account” for that parameter.

Hi Bob,

Thank you for the prompt reply.
We were using the subscription name in azure as the parameter name which was different to the one tied to service principle in octopus. We just renamed the service principle name in octopus to match what is in azure and it worked.

And from your reply now we know why it worked :slight_smile: – so thanks again.

You are welcome! Happy Deployments!