Deployment image from azure container registery to a web app

(Ofer) #1

Hello
I am trying to Deploy image from azure container registry to a web app.
I have configured a Feed successfully and I have choose step called Docker run, It can read the docker image name but fails to load the version number, next I’ve tried the web app deploy and same it fails retrieve the pakcgae/docker image version number, what i am doing wrong ?

I have follow this to create the feed : https://octopus.com/docs/packaging-applications/package-repositories/docker-registries/azure-container-services

I am just confused which step is the right step to use to deploy the latest version

Thanks

(Michael Richardson) #4

Hi,

We’re sorry to hear you’ve had some difficulties.

Regarding Octopus failing to load the image versions, this could be due to them not being SemVer. Octopus requires that versions are in SemVer form. Could this be the problem?

Also, if I understand your question correctly, you are trying to deploy a container image to an Azure Web App? If so, you will not be able to use the Docker Run step.

You will need to follow these steps:

  1. Add your container registry as a package feed in Octopus
  2. Add your Azure subscription as an account
  3. Add your Azure Web App as a deployment target, and give it a role.
  4. Add Run an Azure Powershell Script to your deployment process.
  5. Set the Execution Location of your script to Run on a Worker on behalf of each deployment target, and then in the On Behalf Of field select the role you used on the deployment target.
  6. Add your container image as a referenced package on the step
  7. In the script body of the step, this is where you will need to deploy the image to your web app. It should look something like the sample below:
$ResourceGroupName = $OctopusParameters["Octopus.Action.Azure.ResourceGroupName"]
$AppName = $OctopusParameters["Octopus.Action.Azure.WebAppName"]
$ImageName = $OctopusParameters["Octopus.Action.Package[aspnetapp].Image"]
$RegistryUrl = $OctopusParameters["Octopus.Action.Package[aspnetapp].Registry"]

# Set docker image
az webapp config container set `
    --resource-group $ResourceGroupName `
    --name $AppName `
    --docker-custom-image-name $ImageName `
    --docker-registry-server-url $RegistryUrl

Note that aspnetapp should be replaced with whatever you named your container image package reference. Information on the variables available to your script can be found here.

I hope that helps. We’re aware this scenario isn’t a simple as it should be. Please reach out if we can assist further :slight_smile:

(Ofer) #5

Many thanks

We’re OK retrieving the package and the image tag the only thing is the warning:

WARNING: No credential was provided to access Azure Container Registry. Trying to look up…
WARNING: Retrieving credentials failed with an exception:'No resource or more than one were found with name ‘somename’.