As a follow-up on the presentation I did at CloudBrew about Azure Static Web Apps I want to write a series of blog posts.
- Part I - Using the VS Code Extension
- Part II - Using the Astro Static Site Generator
- Part III – Deploying to multiple environments
- Part IV – Password protect your environments
- Part V – Traffic splitting
- Part VI – Authentication using pre-configured providers
- Part VII – Application configuration using staticwebapp.config.json
- Part VIII(this post) – API Configuration
In the last post in this series, I talked about the application configuration. But an Azure Static Web App can be a combination of an application part and an API part. Today we’ll have a look on how to configure the API part.
Storing values
API configuration settings can be set through the Azure Portal or Azure CLI and are stored in the backend of your Azure Static Web App in an encrypted format.
Azure Portal
To set a configuration value through the Azure Portal, go to Configuration:
Select the environment for which you want to specify configuration values and click on Add:
Enter a name and a value and click on OK:
Click on Save to apply the settings.
Azure CLI
If you prefer to use the Azure CLI, you can use the az staticwebapp appsettings
command:
az staticwebapp appsettings set --name <YOUR_APP_ID> --setting-names "message=Hello world"
Using the stored values
The values stored are available as environment variables inside your Azure Function:
More information
Configure application settings for Azure Static Web Apps | Microsoft Learn