Hi @Elliot Stoner Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.I haven't tried the http call method, but I was able to get the output from the stored procedure using pyodbc
driver.
Your understanding on the following This makes me think that it's automatically trying to bind the "calculatedName" property to the queryParams is correct. The values for the parameters are loaded before the function app gets to the following lines of code. I believe this is done from the binding extraInputs: [sqlInput] before the http trigger function gets invoked.
Here is my Stored procedure in SQL
CREATE or Alter PROCEDURE SearchName
@Name NVARCHAR(100),
@MatchedCount INT OUTPUT
AS
BEGIN
SET NOCOUNT ON;
SELECT @MatchedCount = COUNT(*)
FROM Test
WHERE Name = @Name ;
Return @MatchedCount
END;
My Python function app for fetching the result
import { app, HttpRequest, HttpResponseInit, InvocationContext, input } from "@azure/functions";
const sqlInput = input.sql({
commandText: `EXEC [dbo].[SearchName] @Name, @MatchedCount OUTPUT; SELECT @MatchedCount as N'@MatchedCount';`,
commandType: 'Text',
parameters: '@Name={Query.name},@MatchedCount={Query.matchedCount}',
connectionStringSetting: 'sqlconnectionstring',
});
export async function httpTriggerTypeScript(request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> {
context.log(`Http function processed request for url "${request.url}"`);
const name = request.query.get('name') || await request.text() || 'world';
let matchedCount: number = -1;
try {
const result = await context.extraInputs.get(sqlInput);
matchedCount = result[0]['@MatchedCount'];
context.log(`Stored procedure returned matchedCount: ${matchedCount}`);
return {
body: `Matched count is ${matchedCount}`
};
} catch (err) {
context.log('Error fetching data from SQL', err.message);
return {
status: 500,
body: `Internal Server Error: ${err.message}`
};
}
};
app.http('httpTriggerTypeScript', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
extraInputs: [sqlInput],
handler: httpTriggerTypeScript
});
Hope this helps! Please let us know if you have any questions or need further assistance.
If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.