Load Connection String from Config File in Azure Functions

前端 未结 6 1732
伪装坚强ぢ
伪装坚强ぢ 2020-12-20 13:09

In my Azure Function I am using a Library which establishes a connection to an SQL server via the ConnectionString from the ConfigurationManager like this:

v         


        
6条回答
  •  情歌与酒
    2020-12-20 13:45

    Add file local.setting.json

      {
        {
          "IsEncrypted": false,
           "Values": {
          "AzureWebJobsStorage": "UseDevelopmentStorage=true",
          "AzureWebJobsDashboard": "UseDevelopmentStorage=true",
    
          "tenantId": "You tenantId",
          "resource": "https://management.azure.com/",
          "ClientSecret": "You ClientSecret, Key from App Registry",
          "ClientId": "You ClientId, Application ID from App registry",
    
          "subscriptionId": "You subscriptionId",
          "resourceGroupName": "Your resourceGroupName",
          "serverName": " Your SQL Server",
          "databaseNameDW": "Your Database",
          "apiversion": "2017-10-01-preview"      
        }
    }
    

    In C# Code use:

    private readonly static string tenantId = ConfigurationManager.AppSettings["tenantId"];
    

提交回复
热议问题