Azure Functions部署后出现连接字符串格式错误求助
部署Azure Functions后SQL连接字符串格式错误问题
我排查后确定问题出在ConnectionString上。本地Azure Functions应用使用该连接字符串完全正常,但部署到Azure后触发以下错误:
2024-06-22T11:08:57Z [Verbose] Sending event Create
2024-06-22T11:08:57Z [Verbose] Sending exception event: Format of the initialization string does not conform to specification starting at index 0.
供参考的连接字符串:
Server=tcp:buzzats.database.windows.net;Initial Catalog=buzzats;Persist Security Info=False;User ID=ibraheem;Password=...;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
我的Azure Functions应用使用Node JS v20作为运行时,以下是HttpTrigger的示例代码:
const { app, input } = require("@azure/functions"); const sql = input.sql({ commandText: "SELECT * FROM [dbo].[Students]", commandType: "Text", connectionStringSetting: "SqlConnectionString", }); app.http("getStudents", { methods: ["GET"], authLevel: "anonymous", extraInputs: [sql], handler: async (request, context) => { try { const response = await context.extraInputs.get(sql); return { status: 200, body: JSON.stringify(response) }; } catch (error) { return { status: 200, body: error.message }; } }, });
我已尝试所有可能的方法但仍无法解决该错误,在StackOverflow上遍寻解决方案也无果,且严格遵循了微软官网的操作步骤。
内容的提问来源于stack exchange,提问作者Ibraheem Haseeb
相关产品推荐
相关产品推荐

