Azure DevOps - Configure Connection Strings for Azure Function App
insights Stats
Data analytics, application development with Microsoft Azure cloud platform.
I love Azure DevOps as it is very simple to use yet powerful. If you happen to use Azure DevOps release pipeline to deploy your Azure Functions, you may find out that there is no place to configure Connection strings.
The common approach is to use Azure Function App task to deploy Azure Functions. Regardless of using YAML or the classic UI, you won't find a place to configure connection strings like Entity Framework connection strings for your app. Go to task documentation, there is no settings for connection strings.
Since the application is deployed as an web application, we can also use Azure App Service Settings task to configure connection strings for your Azure Function App: Azure App Service Settings task - Azure Pipelines.
Use Azure App Service Settings task
Follow these steps to set it up.
- Add Azure App Service Settings task to your Azure release pipeline.
- Select your subscription, App Service Name (in this case, the Azure Function App name) and Resource group.
- Now you can configure the settings include connectionStrings: Connection strings to be entered using JSON syntax. Values containing spaces should be enclosed in double quotes.
- In Connection Strings of the task property, input the following:
[ { "name": "DefaultConnection", "value": "$(DefaultConnection)", "type": "SQLAzure", "slotSetting": false } ]
The above input will create a connection string named DefaultConnection.
- Save the pipeline.
Run the release pipeline
Kick of the deploy and wait till the task is completed:
Go to Azure portal, you will find the connection string is configured: