1
votes

I am deploying a website written in Asp.Net Core 2.2 which has a connection to an Azure Sql Database. Where do I set the Connection String in the Azure App Service deploy task in Azure DevOps?

In my WebApp, the DefaultConnection is in appsettings.json which works fine locally. I want to override this when deployed to Azure.

I tried setting -DefaultConnection $(DefaultConnection) in the Application and Configuration Settings section of the Azure App Service deploy task but the Connection String did not get set. The value is in a variable in Azure DevOps.

Where am I going wrong?

4
Put the connection string in a key vault. Retrieve the connection string from the key vault at runtime.Daniel Mann

4 Answers

4
votes

There is a new preview task Azure App Service Setting can help you with. enter image description here

You can refer to this Deploy Connection Strings using Azure App Service Deploy #9017

3
votes

It may need you define the value of ConnectionString in the Azure app service.

ConnectionString in Azure

This could not be configured in Variables if you want to set it in Configuration setting.

0
votes

The parameter name used in the deployment should be ConnectionStrings_DefaultConnectionString as the appsettings.json uses this hierarchy for connection strings.

i.e. -ConnectionStrings_DefaultConnectionString $(DefaultConnection)

-3
votes

change it in appsettings.json , it should work