top of page
  • Writer's pictureMax Morrow

Azure DevOps: Deploying Docker Containers To Azure App Services Using YAML Pipelines

So, you've got a few Docker containers lying around and you're looking for a cheap, fast solution for deploying them. Azure App Services might be your answer. Microsoft offers very inexpensively licensing that ranges from free to highly scalable. Personally, I find app services great for low to medium-high traffic applications.

Deploying your Docker Containers is relatively simple too. There's a bit of configuration on the Azure side, but your deployments are a breeze.

Something I should note is that this is an example of the simplest possible workflow, your environment may not match exactly. If you have any questions about making this work for you, feel free to reach out!

Step 1: Getting Your App Service Ready

Let's walk you through how to set up an App Service that will consume a container to get you started. If you already have one good to go, feel free to skip to step 2.

  1. Head to the Azure Portal

  2. Search for "App Services" and head to the App Services page

  3. In the upper left-hand corner, click "Create"

  4. On the "Create Web App" page, enter your subscription, resource group, and name.

  5. For Publish, choose "Docker Container"

  6. For Operating System, choose "Linux"

  7. Set the region & plan accordingly

8. Click Next : Docker >

9. You'll notice you have an option to change the container now. Leave it as-is.

10. Click Review + Create

11. Click Create

12. Save the name of the Resource Group, Name, and Region we'll need that in Step 3.

Step 2: Creating Your Azure Container Registry

Alright, you have your App Service ready to go. The next step is creating a place for you to publish your containers within Azure. To do that, let's walk through the steps to set up a new Azure Container Registry (ACR).

  1. Search for container registry

  2. Access the Container registries page in the Azure Portal

  3. Click + Create

  4. Fill in your resource group, registry name, and location

  5. Save the name of the registry, we'll need it in Step 3

6. Click Review + Create

7. Click Create

Step 3: Putting Together Your Pipeline

So, you have your App Service, your Azure Container Registry is good to go. You're finally ready to push some code.

Now at first, it's going to seem like we're really not deploying anything, but hang tight until the last step.

  1. Within your Azure DevOps tenant, head to Project Settings > Service Connections

  2. Click New service connection in the upper left hand corner

  3. Choose Docker Registry and click Next

  4. Choose Azure Container Registry

  5. Select the Subscription & Container Registry that you used in Step 2 to create your container

  6. Click Save

  7. Now, head to your pipeline and add the Docker@2 task within your YAML pipeline (or classic!)

  8. Add the following parameters:

    1. command: push

    2. tags: **YOUR TAGS**

    3. containerRegistry: **NAME OF YOUR SERVICE CONNECTION**

    4. repository: **REPOSITORY URL FROM STEP 2**

  9. When you're done, your docker push task should look something like this:

   - task: Docker@2
     displayName: "Release: Push Docker Image to ACR"
      containerRegistry: ServiceConnectionName
      command: push
      tags: latest

10. Run your pipeline and wait for it to finish.

11. Head back to your App Service in Azure and click Deployment Center

12. Click Container Registry at the top

13. Select your subscription, registry, and image tag

14. Click Save & You're done!

Bonus: Troubleshooting

My Tag Isn't Showing Up in the "Tag" Dropdown within Azure Deployment Center

If your tag isn't being displayed, then more than likely, your container didn't get pushed in the pipeline. Double-check that your pipeline ran successfully in Step 3.10.

Also, head to your Azure Container registry and check to ensure that your container exists.

472 views1 comment


5 days ago
bottom of page