Step-by-Step Azure App Configuration Deployment using Azure DevOps Pipeline
Introduction:
This document provides a step-by-step guide on how to utilize Azure Pipelines to push key-values from a configuration file to an Azure App Configuration store. By following these instructions, you can efficiently manage your application settings and configurations using Azure DevOps.
Also provides a comprehensive guide on setting up an Azure DevOps pipeline to pull key-value pairs from Azure App Configuration using Azure Pipelines.
Implementing a Pipeline to Push & Pull Key-Values to Azure App Configuration using Azure Pipelines
Prerequisites:
Before proceeding with setting up the pipeline, ensure you have the following prerequisites in place:
• Azure subscription
• Azure App Configuration store
• Azure DevOps project
• Azure App Configuration Push & Pull task:
Download this task for free from the Visual Studio Marketplace.
• Azure Pipelines agent version 2.206.1 or later
• Node version 16 or later for running the task on self-hosted agents
Azure DevOps Pipeline for Push Key-Value Pairs from Azure App Configuration
Create a Service Connection
• In Azure DevOps, navigate to the project that contains your target pipeline.
•Go to Project settings and under Pipelines, select Service connections.• Click on New service connection and choose Azure Resource Manager. • Select the appropriate Authentication method and enter your subscription, resource group, and a name for your service connection.
• Manage service principal and add role assignments to grant necessary permissions.Assign Role Assignments
• Go to your target App Configuration store.
• In the left menu, choose Access control (IAM).
• Select Add role assignments and assign the role of App Configuration Data Owner to the service principal associated with your service connectionUse in Builds
• Navigate to the build pipeline page in Azure DevOps.
• Search for the Azure App Configuration Push task..
• Configure the task parameters such as Azure subscription, App Configuration Endpoint, and Configuration File Path.
• Save and queue a build to push key-values from the configuration file to the App Configuration store.Use in Releases:
• Go to the release pipeline page in Azure DevOps.
• Choose an existing release pipeline or create a new one.
• Add the Azure App Configuration Push task to the desired stage within the release pipeline.
• Configure the task parameters and save to push key-values during the release process.• Troubleshooting
• Enable debug logs by setting the pipeline variable system.debug to true if any unexpected errors occur during the execution of the task. Task parameters:
• Import Mode: The default value is All. Determines the behavior when importing key-values.
All: Imports all key-values in the configuration file to App Configuration. o Ignore-Match: Imports only settings that have no matching key-value in App Configuration. Matching key-values are considered to be key-values with the same key, label, value, content type and tags.
Dry Run: Default value is Unchecked. o Checked: No updates will be performed to App Configuration. Instead any updates that would have been performed in a normal run will be printed to the console for review. o Unchecked: Performs any updates to App Configuration and does not print to the console.
Separator: The separator that's used to flatten .json and .yml files.
Depth: The depth that the .json and .yml files will be flattened to.
Prefix: A string that's appended to the beginning of each key pushed to the App Configuration store.
Label: A string that's added to each key-value as the label within the App Configuration store.
Content Type: A string that's added to each key-value as the content type within the App Configuration store.
Tags: A JSON object in the format of {"tag1":"val1", "tag2":"val2"}, which defines tags that are added to each key-value pushed to your App Configuration store.
- task: AzureAppConfigurationPush@7
inputs:
azureSubscription: 'connection-name'
AppConfigurationEndpoint: 'https://testdemo988.azconfig.io'
ConfigurationFile: 'appconfigData.json'
Separator: ':'
Label: 'prod'
Strict: false
ImportMode: 'All'
Snapshots:
AppconfigData.json have all the key & values that need to store in azure app configuration.
Azure DevOps Pipeline for Pulling Key-Value Pairs from Azure App Configuration
Step 1: Create a Service Connection
• Navigate to your Azure DevOps project and select Project settings.
• Under Pipelines, choose Service connections and click on New service connection.
• Select Azure Resource Manager and choose the authentication method.
• Enter subscription details and create the service connection.
• Manage service principal and note the display name.
Step 2: Add Role Assignments
• Go to your target App Configuration store.
• Select Access control (IAM) from the left menu.
• Click on Add role assignments in the right pane.
• Assign the App Configuration Data Reader role to the service principal associated with the service connection.
• Review and assign the role.
Step 3: Use in Builds
• Navigate to the build pipeline page in Azure DevOps.
• Search for the Azure App Configuration Task.
• Configure the task parameters
• Set Azure subscription to the service connection name.
• Set App Configuration Endpoint to your configuration store's endpoint.
• Leave default values for other parameters.
• Save and queue a build to test the task.
Step 4: Use in Environment Variables
• Search for the Power shell Task.
• Configure the task parameters.
• Select the Edit button and add the Azure App Configuration Pull Task.
• Configure parameters similar to the build pipeline setup.
• Save and queue a build to test the task.
- task: PowerShell@2
inputs:
targetType: 'inline'
script: 'echo "$env:API_URL"'
Snapshots:
Conclusion:
By following these steps, you can seamlessly push key-values & pull key-values from your configuration files to your Azure App Configuration store using Azure Pipelines. This streamlined process ensures efficient configuration management within your DevOps workflows.
Reference link:
https://learn.microsoft.com/en-us/azure/azure-app-configuration/push-kv-devops-pipeline
https://learn.microsoft.com/en-us/azure/azure-app-configuration/pull-key-value-devops-pipeline