Create Docker Image Of Azure Logic App Standard And Deploy In Azure Kubernetes Service

This article gives you an overview of,

  • How to create Docker Image of Azure Logic app
  • How to push image into azure Container Registry (ACR) and
  • How to deploy ACR image into AKS

Pre-requisites

  • Docker for Desktop
  • Docker extension for VS code
  • Logic App (Standard) Extension
  • C# Extension
  • Azure Account
  • Stoarge account

Create a stateless workflow locally in Visual Studio Code

I am using VS Code for developing Azure Logic App Standard.

image

image

It will create a skeleton of workflow

image

UseDevelopmentStorage=true property lets us run logic apps locally using Azure Storage Emulator.

Right click on the workflow.json file and select open in Designer to view the workflow designer

image

image

Select Run->Start Debugging or F5 to start the logic apps locally, finally the execution displays the following to show the logic apps is up and running.

Add a docker file to your project as below named “DockerFile”.

FROM mcr.microsoft.com/azure-functions/node:3.0
ENV AzureWebJobsStorage DefaultEndpointsProtocol=<BlobStorageConnectionString>
ENV AzureWebJobsScriptRoot=/home/site/wwwroot AzureFunctionsJobHost__Logging__Console__IsEnabled=true FUNCTIONS_V2_COMPATIBILITY_MODE=true
ENV WEBSITE_HOSTNAME localhost
ENV WEBSITE_SITE_NAME weatherforecast
ENV AZURE_FUNCTIONS_ENVIRONMENT Development
COPY . /home/site/wwwroot

And modify the local.settings.json to have the storage account as the

Build the docker container image by using the docker file by running the below command

Make sure to tag like .azurecr.io\imagename to push image into ACR

docker build --tag <ImageName> .

Run the container locally by using the below command

docker run -p 8080:80 <ImageName>

You can see images and instances in Docker extension

image

Navigate to the Azure storage account provided in the docker definition and open blob containers. You will see the following folders

image

Push Docker Image to Azure Container Registry

Create Azure Container registry manually on Azure Portal

image

Enable Access key to login into ACR

This helps to login into acr and push images

How to create Docker Image of Azure Logic App Standard

Login into Docker Registry

docker login laacr.azurecr.io

image

Tag and Push Image to ACR

Use docker tag to create an alias of the image with the fully qualified path to your registry.

docker tag laimage laacr.azurecr.io/laimage
docker push laacr.azurecr.io/laimage

image

How to create Docker Image of Azure Logic App Standard

Create Azure Kubernetes cluster - AKS

How to create Docker Image of Azure Logic App Standard

Link ACR with AKS

az aks update -n laaks -g acr --attach-acr laacr

Deploy Logic App Image from ACR into AKS

Go to AKS - >

- apiVersion: v1
  kind: Namespace
  metadata:
    name: azure-la
  spec:
    finalizers:
      - kubernetes
- apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: azure-la-front
    namespace: azure-la
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: azure-la-front
    template:
      metadata:
        labels:
          app: azure-la-front
      spec:
        nodeSelector:
          beta.kubernetes.io/os: linux
        containers:
          - name: azure-la-front
            image: laacr.azurecr.io/laimage
            resources:
              requests:
                cpu: 100m
                memory: 128Mi
              limits:
                cpu: 250m
                memory: 256Mi
            ports:
              - containerPort: 80
            env:
              - name: AzureWebJobsStorage
                value: <<connectionstring>>
- apiVersion: v1
  kind: Service
  metadata:
    name: azure-la-front
    namespace: azure-la
  spec:
    type: LoadBalancer
    ports:
      - port: 80
    selector:
      app: azure-la-front

How to create Docker Image of Azure Logic App Standard

Check if app service is deployed

image

Fetch logic app URL using callback URL

Fetch master key from blob storage which will help in fetching callback URL

How to create Docker Image of Azure Logic App Standard

Fetch callback URL using URL

http://20.76.240.221:80/runtime/webhooks/workflow/api/management/workflows/Stateful1/triggers/manual/listCallbackUrl?api-version=2020-05-01-preview&code=

image

You can use postman to test logic app

Logic App URL - http://20.76.240.221:80/api/Stateful1/triggers/manual/invoke?api-version=2020-05-01-preview&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=

How to create Docker Image of Azure Logic App Standard