Search code examples
azureconfigurationazure-web-app-serviceasp.net-core-webapiconnection-string

Azure App Service Connection String Not Working


I am working on an asp.net core web api project and its hosted on azure app service. What I'm trying is to put my cosmos db connection string in app service connection string. I added a document db type connection string but when I'm calling it, it wont get read.

enter image description here

I tried this,

CosmosDBAccountPrimaryKey = _configuration.GetConnectionString("DOCDBCONNSTR_COSMOSDBCONNSTR");

this also,

CosmosDBAccountPrimaryKey = _configuration.GetConnectionString("COSMOSDBCONNSTR");

But none worked. For just checking i tried to put the connection string in app setting variables and tried this,

CosmosDBAccountPrimaryKey = _configuration["COSMOSDBCONNSTR"];

This worked but when I'm calling from connection string, its not working.


Solution

  • The issue was Type of connection string when creating it in app service. I was setting its type to Document DB which was not working. But when I set it up to Custom then it started working