如何在 Azure Function 环境中设置 linq2db 连接字符串

How to set linq2db connection string in Azure Function enviroment

我已经从 linq2db T4 模板生成数据模型并在本地开发和调试我的 azure 函数,在 local.settings.json 中设置连接字符串。将函数部署到 Azure 后,我在 Azure 门户的应用程序设置页面为我的 Azure SQL 数据库设置了相同的连接字符串,但函数无法连接到数据库,它抛出此异常:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsDashboard": "",
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
  },
  "ConnectionStrings": {
    "IntegrationSqlDb": "constr here"
  }
}

Portal Application settings

通过替换解决问题

public IntegrationSqlDbDB(string configuration)
    : base(configuration)
{
    InitDataContext();
}

public IntegrationSqlDbDB() : base("IntegrationSqlDb")
{
    InitDataContext();
}

由 T4 模板代码生成。 新手请见谅