Stylized laptop screen showing Octopus logo connected to cogs in the cloud, with a clipboard to the right.

Using Azure App Config with Octopus

Mark Harrison

I've written previously about extending the functionality of Octopus to integrate with cloud-based services, like Azure Key Vault and AWS Secrets Manager, using step templates. We're committed to providing more ways for our customers to succeed with Octopus, so we're always creating more step templates that integrate with other cloud-based services.

In this post, I walk through 2 new Azure App Configuration step templates we introduced:

  1. The Azure AppConfig KV - Retrieve Values step. We designed this to retrieve values from an Azure App Configuration instance that you can use in your deployments or runbooks.
  2. The Azure Function - Set AppSettings from Azure AppConfig step. We designed this to retrieve values from an Azure App Configuration instance and add them to an Azure Function's AppSettings.

Before you start

This post assumes you know how to use custom step templates and the Octopus community library.

I also don't go into great detail about Azure App Configuration concepts or how to set it up. You can learn more by reading the Azure App Configuration overview from Microsoft.

The step templates in this post retrieve values from an Azure App Configuration instance using the Azure Command Line Interface (CLI), known as az. You need to download the CLI and install it on the deployment target or Worker before the steps can execute successfully. I tested the step templates on Windows and Linux (with PowerShell Core installed).

Authentication

Before you can retrieve values from an Azure App Configuration instance, you must authenticate with Azure. In their security concepts documentation, Microsoft notes:

By default, requests can be authenticated with either Microsoft Entra credentials, or by using an access key. Of these two types of authentication schemes, Microsoft Entra ID provides superior security and ease of use over access keys, and is recommended by Microsoft.

In Octopus, you can achieve authentication with an Azure App Configuration instance with an Azure account, using a service principal.

In addition to accessing resources in Azure, your service principal may need further permissions configured to access and retrieve values stored in Azure App Configuration. To learn more, read the guide Authorize access to Azure App Configuration using Microsoft Entra ID.

Retrieving Values

The Azure AppConfig KV - Retrieve Values step template retrieves one or more keys/values from an Azure App Configuration instance. It then creates output variables for each one retrieved.

For each key/value, you can optionally provide a custom output variable name.

Retrieving a single key/value requires:

  • An Azure account with permission to retrieve key/values from the Azure App Config instance
  • The name of the Azure App Config instance to retrieve the key/value from
  • The name of the key to retrieve

An advanced feature of the step template lets you retrieve multiple keys at once. This requires entering each key name on a new line. A wildcard search is also supported using the * notation in the Key Names parameter.

Note: Combining a wildcard search with custom output variable names is not supported.

For each key/value retrieved, an output variable gets created for subsequent steps. By default, you only see a count of the number of variables created in the task log. To see the names of the variables in the task log, change the Print output variable names parameter to True.

Retrieve Values step template parameters

The step template uses the following parameters:

  • Azure Account: An Azure account with permissions to retrieve keys/values from the Azure App Config instance.

  • Config Store Name: The name of the Azure App Config instance. Provide this or the Config Store Endpoint.

  • Config Store Endpoint: The endpoint for the Azure App Config instance. Provide this or the Config Store Name.

  • Retrieval Method: Choose between retrieving all configuration values or each entry individually. Retrieving all values from the App Config instance is usually more efficient, but could result in the return of a larger payload.

  • Key Names: Specify the names of the keys to be returned from Azure App Configuration, in the format: KeyName | OutputVariableName where:

    • KeyName is the key to retrieve. Wildcards are supported by adding * at the end of the key name.
    • OutputVariableName is the optional Octopus output variable name to store the key's value in. If this value isn't specified, an output name gets generated dynamically based on the matching key name.

    Note: You can retrieve multiple keys by entering each one on a new line.

  • Labels (optional): Labels are an attribute of keys. Provide one or more labels in the format label1,label2 to retrieve only selected keys tagged with those labels.

    Note: You can include both label values and specify key names.

  • Save sensitive output variables: Set the Octopus output variables to sensitive values. Default: False.

  • Suppress warnings: Suppress warnings from being written to the task log. For example, when a supplied key can't be found in the Azure App Config instance. Default: False.

  • Treat Warnings as Errors: Treats warnings as errors. If enabled, the Suppress Warnings parameter is ignored. Default: True.

  • Create AppSettings JSON: Create an Azure App Service AppSettings JSON output variable called AppSettingsJson. This can be useful when using the Octopus Azure App Service step and you want to dynamically create the JSON app settings for the step. Default: False.

  • Print output variable names: Write out the Octopus output variable names to the task log. Default: False.

Parameters for the Azure AppConfig Retrieve Values step

Using the Retrieve Values step

The Azure AppConfig KV - Retrieve Values step gets added to deployment and runbook processes in the same way as other steps.

After you add the step to your process, fill out the parameters in the step:

The Azure AppConfig Retrieve Values step used in a process

After you fill in the parameters, you can execute the step in a runbook or deployment process. On successful execution, any matching key/values get stored as output variables. If you configured your step to print the variable names, they appear in the task log:

Task log output for the Azure AppConfig Retrieve Values step

In subsequent steps, you can use output variables created from matching key/values in your deployment or runbook.

Tip: Remember to replace Azure AppConfig KV - Retrieve Values with the name of your step for any output variable names.

Set Function Application settings

The Azure Function - Set AppSettings from Azure AppConfig step template retrieves one or more keys/values from an Azure App Configuration instance. It then adds them to an Azure Function's Application settings for each one retrieved.

For each key/value, you can optionally provide a custom name to use in the Function's settings.

Retrieving and setting a single key/value requires:

  • An Azure account with permission to both retrieve keys/values from the Azure App Config instance and publish the settings to an Azure App Function
  • The name of the Azure App Config instance to retrieve the key/value from
  • The name of the key to retrieve
  • The Azure Function
    • Name
    • Resource group name

An advanced feature of the step template offers support for retrieving multiple keys at once. This requires entering each key name on a new line. A wildcard search is also supported using the * notation in the Key Names parameter. You can also combine retrieved values with additional parameters supplied to the step using the Additional AppSettings parameter.

Note: Combining a wildcard search with custom setting names is not supported.

Set Function Application settings parameters

The step template uses the following parameters:

  • Azure Account: An Azure account with permission to both retrieve values from the Azure App Config instance and publish to the App Function.

  • Config Store Name: The name of the Azure App Config instance. Provide this or the Config Store Endpoint.

  • Config Store Endpoint: The endpoint for the Azure App Config instance. Provide this or the Config Store Name.

  • Retrieval Method: Choose between retrieving all configuration values or each entry individually. Retrieving all values from the App Config instance is usually more efficient, but could result in the return of a larger payload.

  • Key Names: Specify the names of the keys to be returned from Azure App Configuration, in the format: KeyName | CustomSettingName where:

    • KeyName is the key to retrieve. Wildcards are supported by adding * at the end of the key name.
    • CustomSettingName is the optional name to set for the AppSetting value in the App Function. If this value isn't specified, the original key gets used.

    Note: Multiple keys can be retrieved by entering each one on a new line.

  • Labels (optional): Labels are an attribute of keys. Provide one or more labels in the format label1,label2 to retrieve only selected keys tagged with those labels.

    Note: You can include both label values and specify key names.

  • Suppress warnings: Suppress warnings from being written to the task log. For example, when a supplied key can't be found in the Azure App Config instance. Default: False.

  • Treat Warnings as Errors: Treats warnings as errors. If enabled, the Suppress Warnings parameter is ignored. Default: True.

  • Azure Function App Name: The name of the Azure App Function.

  • Resource Group: The name of the resource group where the Function App is located.

  • Slot (optional): The name of the slot for the Azure App Function. Defaults to the production slot if not specified.

  • Additional AppSettings: Specify the name and values of any additional settings to be applied to the Azure App Function in the format: KEY | VALUE where:

    • KEY is the name of the app setting to add.
    • VALUE is the value to be used. Octopus variables can be used here.

    Note: You can add multiple settings by entering each one on a new line. As a result, any value for a key that spans multiple lines will result in an error.

Parameters for the Set Azure Funtion Application settings step

Using the Setting Function Application settings step

The Azure Function - Set AppSettings from Azure AppConfig step gets added to deployment and runbook processes in the same way as other steps.

After you add the step to your process, fill out the parameters in the step:

The Set Azure Funtion Application settings step used in a process

After you fill in the parameters, you can execute the step in a runbook or deployment process. On successful execution, any matching key/values from the Azure App Config instance get published to the Azure App Function, and details appear in the task log:

Task log output for the Set Azure Funtion Application settings step

Conclusion

The step templates covered in this post show that it's easy to integrate with Azure App Configuration to retrieve the keys/values stored there. You can use these keys/values in subsequent steps in your Octopus deployments or runbooks or publish those values directly as application settings to an Azure App Function.

Watch the video walkthrough: Introducing step templates for Azure App Config

Happy deployments!

Loading...