This is the sample Flask application that uses the Azure App Configuration Service Deploy a Python (Django or Flask) web app to Azure App Service. For instructions on how to create the Azure resources and deploy the application to Azure, refer to the Quickstart article.
A sample Django application is also available.
If you need an Azure account, you can create one for free.
You must have an Azure subscription, and a Configuration Store to use this package.
To create a Configuration Store, you can either use Azure Portal or if you are using Azure CLI you can simply run the following snippet in your console:
az appconfig create --name <config-store-name> --resource-group <resource-group-name> --location eastus
az appconfig kv set --name <config-store-name> --key testapp_settings_message --value "Hello from Azure App Configuration"
az appconfig kv set --name <config-store-name> --key testapp_settings_font_size --value "30px"
az appconfig kv set --name <config-store-name> --key testapp_settings_color --value "azure"
az appconfig kv set --name <config-store-name> --key sentinel --value "1"
az appconfig feature set --name <config-store-name> --feature Beta
Requires Key Vault with Secret already created.
az appconfig kv set-keyvault --name <config-store-name> --key secret_key --secret-identifier <key-vault-reference>
Install the Azure App Configuration Provider client library for Python and other dependencies with pip:
pip install -r requirements.txt
Set your App Configuration store endpoint as an environment variable.
setx AZURE_APPCONFIG_ENDPOINT "your-store-endpoint"
$Env:AZURE_APPCONFIG_ENDPOINT="your-store-endpoint"
export AZURE_APPCONFIG_ENDPOINT="your-store-enpoint"
Start the flask application using the flask command:
flask run
To refresh your configuration, you first update the value in Azure App Configuration, then update the Sentinel value to trigger a refresh.
az appconfig kv set --name <config-store-name> --key testapp_settings_color --value "violet"
az appconfig kv set --name <config-store-name> --key sentinel --value "2"
az appconfig feature enable --name <config-store-name> --feature Beta
Refresh the page in your browser to see the updated value, along with a now visible Beta page.
NOTE: By default refresh can only be triggered every 30 seconds. You might have to wait up to 30 seconds and refresh the page again in order to see a change.