Can I deploy a Docker image to an Azure App Service using Octopus Deploy?

I’m able to deploy a Nuget package successfully to an Azure App Service (a web-app) using Octopus Deploy, but my organization would like to switch to using Docker containers.

Can I make use of the existing Deploy an Azure Web App step and just switch the package feed to my Docker registry?

That is a great question!

It’s not currently possible to deploy a container using our built-in functionality e.g. via the Deploy an Azure WebApp step as this uses webdeploy under the hood.

Use the Deploy an Azure Script step
One option would be to make use of the Deploy an Azure Script step and use the Azure CLI to perform the deployment.

Microsoft provides a number of helpful tutorials on deployment to Azure. One such tutorial in particular provides some useful information on which Azure CLI command you can use to deploy a container image.

Note: If your Docker image is available publicly on DockerHub you can ignore the parts about setting the custom docker image and using Azure’s Container Registry.

Using the Deploy an Azure Script step, I am referencing the Docker image as a Referenced Package which points to my Docker package feed and the container image I want to deploy.

By referencing the docker image (and choosing not to acquire it), I can get the version automatically in the script for me.

Then I add the following in the script itself:

$pi = $OctopusParameters["Octopus.Action.Package[rolling-deploy].PackageId"]
$pv = $OctopusParameters["Octopus.Action.Package[rolling-deploy].PackageVersion"]
$dockerImage = "${pi}:${pv}"

az webapp create --resource-group "ResourceGroupName" --plan "AppServicePlanName" --name "AppServiceName" --deployment-container-image-name $dockerImage

The script calls the az webapp create command. You would need to fill in your own variables in the call for the following:

  • ResourceGroupName
  • AppServicePlanName
  • AppServiceName
  • DockerImage

Each of these could be set up as Octopus variables.

You can find more details on the az webapp create command here.

Note: Using the parameter --deployment-container-image-name is only supported with Linux app services