3

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?

Mark Allison
  • 6,838
  • 33
  • 102
  • 151

4 Answers4

8

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

Huodong
  • 523
  • 8
  • 23
2

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.

IDarkCoder
  • 709
  • 7
  • 18
Amy
  • 37
  • 4
-1

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)

Can Bilgin
  • 471
  • 2
  • 6
  • Didn't work when I tried it , ended up with an AppSetting with the underscore in the name – Rob Sedgwick Nov 16 '21 at 13:06
  • Usually, setting nested variables like this [requires a double-underscore](https://learn.microsoft.com/en-us/azure/app-service/configure-common?tabs=portal). Regardless, this method doesn't work. – Mark Mar 24 '22 at 16:06
-5

change it in appsettings.json , it should work

user5419119
  • 193
  • 1
  • 1
  • 7