Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel7

Objective

You have a working Azure Python Docker function and the source code is managed in a Git repository. The goal of the tutorial is to automate the build and publish of a Docker image to Azure Function App. This automation will include:

...

This tutorial does not cover every feature or configuration option available in FlexDeploy.

Checklist

Checklist

Description

Azure Tenant Id

Azure Tenant Id for the company

Azure Subscription Id

Azure Subscription where the Function App exists

Azure Client ID

Client ID to connect to desired Azure Subscription

Azure Client Key

Password for the Client ID

Azure Client ID permission

The Client ID must have relevant access in the target Function App to deploy code

Azure Function App

The Function App with relevant runtime should already be created

Azure Resource Group

The Resource Group containing the Function App

Azure CLI installation

Azure CLI needs to be installed on the Target Endpoint where the plugin operation will run

Azure CLI in class path

Azure CLI should be added to the classpath on the Target Endpoint. Otherwise, the path can also be set under FlexDeploy environment level property

Docker Registry Address

Target Azure Container Registry URL

Docker Registry User

Azure Client ID to push/pull images against Azure Container Registry

Docker Registry Token/Password

Password for the above Client ID

Docker Registry User permission

The user must have relevant access to push/pull images from Azure Container Registry

Configure Cloud Account

FlexDeploy will connect to your Azure Subscription using the cloud account details provided.

...

It should have a Client ID, Client Key, Tenant Id, and Subscription Id configured in it. The Client ID must have relevant access in the target Function App to deploy code and make other associated changes. (Application Setting update, etc.)

Configure Container Account

Next, a DockerRegistry account needs to be configured under Topology. FlexDeploy will connect to the right Container Registry with provided details and push the Docker image.

...

It should have a Docker Registry Address, Docker Registry User, and Docker Registry Token/Password configured in it.

Git Repository Structure

The Git repository should contain the function codebase. Alongside it can also contain any application setting and connection string related attributes in respective files (any naming convention allowed). These files are not mandatory, however, in case someone has any Application Setting and Connection String property to update this is recommended. Please review the Application Setting and Connection String Property Update section for a more detailed explanation.

...

Below is a sample build workflow to build and push the Docker image and create an artifact from the Application Setting and Connection String files.

...

Step-i: Clone Git Repository

This step will clone the Git repository codebase into the project execution working directory. The Git URL will be retrieved from Source Control configured under Project Configuration.

...

Git Codebase

...

EXPORTED CODEBASE

...

Step-ii: Copy the properties file to the intermediate dir

Application Setting and Connection String JSON files(if applicable/present) will be moved to the intermediate directory. An intermediate directory can have any name, in this case, we are using the artifactsObjects folder inside the TEMP directory. File names are mentioned under File Filter with ‘##’ separated (as advised in the description). Application Setting and Connection String values can also be passed as input to deploy workflow. Application Setting and Connection String files are optional, please review the Application Setting and Connection String property update for a detailed explanation.

...

It's essential to make sure Consumes Artifacts and Produces Artifacts checkbox is marked only when required. Please follow the screenshots for all execution steps to avoid any discrepancy.  

Step-iii: Build and Push Docker image to ACR

Below given is the Docker plugin(buildImage operation) configurations.

...

We have also marked the “Push Image to Repository” checkbox to ensure the created image is deployed to Docker Registry. pushImage operation under the Docker plugin can also be used to push the image to target Docker registry.

If the Container Registry Account is properly configured it would push the image to Docker Registry. In our case, the image will be pushed to Azure Container Registry.

...

Step-iv: Save all from the intermediate dir as Artifact 

Post execution of the above steps the intermediate directory(artifactObjects) should contain files as shown below.

...

The deployFunctions operation returns four output variables. To capture them and use them for further processing/evaluation, create four variables and map them against the output parameters of deployFunctions operation. Return As Output option should be checked.

  1. First, click on the X2 button to open the Variables popup

  2. Next use Create option to add four output variables.

...

Anchor
Source_Control
Source_Control
Source Control

Configure the Source SCM repository under Source Control as shown below.

...

  1. To configure Project specific Source Control one first need to navigate to the Project Configuration tab.

  2. Next, expand the SOURCE CONTROL option from the left-hand pane.

  3. Select SOURCES for configuring the Source Repository

  4. Select the appropriate Source Control Type

  5. Configure Source Repository. For detailed steps of Source Control configuration please refer to Configure Source Control in FlexDeploy

Project Properties

To configure Project specific settings one can navigate to Configuration Properties as shown below.

...

Please refer to this link for the input structure of Application Setting and Connection String both when passed as a file or as input parameter - Application Setting/Connection String file and input content acceptable structure

In case both the Application Setting file and Application Setting input argument are passed, a consolidated list of properties will be considered while updating Function App. If the same attribute is used both in the file and input, the value provided as part of the input will take precedence. The same applies to Connection String as well.

...

Selecting the GREEN circle for DEV will display the configurable properties/Endpoint and allows for the configuration of

Properties

Mandatory field

Description

Slot Name

 

Target slot for deployment

Target slot to swap

Optional

In case slot swap is required

Azure Cloud Account

 

An azure account with relevant details

The absolute path of Azure CLI

Optional

Not required if Azure CLI already added to workflow execution m/c classpath

Docker Server

Optional

Docker server address. Required if Docker Unix Socket is not set.

Docker Server Port

Optional

The port to connect to on the Docker server.

Docker Unix Socket

Optional

The socket the Docker daemon listens on

The default value is [/var/run/Docker.sock]

Registry Account

Docker Registry account with relevant details

GIT Path

Optional

Path to the Git executable. Required only if git is not on class path.

...

In case someone wants to do a slot swap, they can provide the Target Slot to swap with as shown below.

...

executeFunctionAppSlotSwap operation can be used to perform the slot swap.

...

Best way to check logs: https://$func_name.scm.azurewebsites.net/api/logstream or logstream  from console  or https://$func_name.scm.azurewebsites.net/api/logs/Docker

...

The log can be accessed at -https://function0610.scm.azurewebsites.net/api/logstream

...