For a Proof of Concept, I would like to publish an Azure Function from Visual studio to Azure with a different connectionString
value. But I can't figure out how.
In the FunctionApp
there is a local.settings.json
file. I have added a connectionString
to my local database.
local.settings.json
file:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"AzureWebJobsDashboard": ""
},
"ConnectionStrings": {
"DefaultConnection": "Data Source=.\;Initial Catalog=declapp;Integrated Security=False;User ID=*****;Password=*****;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
}
}
I can publish this FunctionApp
to Azure with the generated publish profile but I have a database in Azure which is used by the deployed FunctionApp
. The first time I had to add the connectionString
to the FunctionApp in the Azure Portal. But also when the connectionString
needs to be altered, I can only do it in the Azure Portal.
I would like to know how I can add/alter the connectionString
in the publishing part as below. How can I achieve this?
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"AzureWebJobsDashboard": ""
},
"ConnectionStrings": {
"DefaultConnection": "<Azure sql connectionstring>"
}
}
Just to be clear: I know it`s a bad practice to have (production) values in source control, but it's for a simple Proof of Concept and I don't want to define a CI/CD pipeline just for this.
local.settings.json
is only intended for local development. In Azure, the values will be taken from App Settings of your Function App.
You can set this settings e.g. via the portal, Azure CLI (example), ARM templates (example), or func CLI from local.app.settings
(func azure functionapp publish MyApp --publish-settings-only
).