I have looked around a lot on this issue and turns out the problem is with the ConnectionString. I am using the below connection string and it works absolutely fine locally on my Azure Functions application but when I deploy it on Azure. I get this error:
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.
For reference my connection string is:
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;
I have tried everything possible but I can’t seem to fix this error. I am using Node JS v20
as my runtime for Azure Functions application. Here is below sample code of one 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 };
}
},
});
I have looked all over StackOverflow, but couldn’t find a solution to my problem. I am following the exact steps given on Microsoft site here