且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Azure函数中将连接字符串设置为App设置/环境变量

更新时间:2022-03-09 09:42:47

实际上,您几乎可以获得正确的连接字符串,但是使用了错误的前置字符串.您可以参考此文档的更多详细信息:

Actually you are almost get the right the connection string, however you use the wrong prepended string. Further more detailed information you could refer to this doc:Configure connection strings.

使用哪个字符串取决于您选择的类型,例如在我的测试中,我使用自定义类型.然后我应该使用os.environ['CUSTOMCONNSTR_testconnectionstring']来获取值.

Which string to use it depends on which type you choose, like in my test I use a custom type. Then I should use os.environ['CUSTOMCONNSTR_testconnectionstring'] to get the value.

从文档中您可以找到以下类型:

From the doc you could find there are following types:

  • SQL Server:SQLCONNSTR _
  • MySQL:MYSQLCONNSTR _
  • SQL数据库:SQLAZURECONNSTR _
  • 自定义:CUSTOMCONNSTR _