Get local connection string, working with (Azure Function)

Asked

Viewed 17 times

-1

I would like to know how to pass a connection string to my function, that’s the local.settings.json I found in the documentation of Microsoft

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "<language worker>",
    "AzureWebJobsStorage": "<connection-string>",
    "AzureWebJobsDashboard": "<connection-string>",
    "MyBindingConnection": "<binding-connection-string>"
  },
  "Host": {
    "LocalHttpPort": 7071,
    "CORS": "*",
    "CORSCredentials": false
  },
  "ConnectionStrings": {
    "SQLConnectionString": "<sqlclient-connection-string>"
  }
}

I know that so :

var cnnString = Environment.GetEnvironmentVariable("SqlConnectionString");

I can get the application environment variable in Azure, how can I get the same result in my localhost?

1 answer

0


You will need to inform these connection strings in your appsettings.local.json or configure them as environment variables.

To run your code you can set the build parameter in the debug, just right-click on your start up project and then go to prides.

inserir a descrição da imagem aqui

You can also do this by command line, using the setx if using Windows Vista or above

setx ASPNETCORE_ENVIRONMENT "Local"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.