Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Azure App Configuration Console App Example

This example demonstrates how to use the refresh functionality of Azure App Configuration in a console/command-line application.

Overview

This console application:

  1. Loads configuration values from Azure App Configuration
  2. Binds them to target configuration struct
  3. Automatically refreshes the configuration when changed in Azure App Configuration

Running the Example

Prerequisites

You need an Azure subscription and the following Azure resources to run the examples:

The examples retrieve credentials to access your App Configuration store from environment variables.

Add key-values

Add the following key-values to the App Configuration store and leave Label and Content Type with their default values:

Key Value
Config.Message Hello World!
Config.Font.Color blue
Config.Font.Size 12

Setup

  1. Initialize a new Go module.

    go mod init console-example-refresh
  2. Add the Azure App Configuration provider as a dependency.

    go get github.com/Azure/AppConfiguration-GoProvider/azureappconfiguration
  3. Set the connection string as an environment variable:

    # Windows
    set AZURE_APPCONFIG_CONNECTION_STRING=your-connection-string
    
    # Linux/macOS
    export AZURE_APPCONFIG_CONNECTION_STRING=your-connection-string

Run the Application

go run main.go

Testing the Refresh Functionality

  1. Start the application
  2. While it's running, modify the values in your Azure App Configuration store
  3. Within 10 seconds (the configured refresh interval), the application should detect and apply the changes
  4. You don't need to restart the application to see the updated values