I have been trying out the Azure Functions binding for Open AI and the text completion sample. I kept having a problem getting a 404 resource not found error as shown below. The problem was pretty simple but it took me an hour to figure it out so just making notes here to save someone else being as stupid as me.

In reality the problem wouldn’t have happened if id came in completely new, but id been messing around with other samples. When I set up my app settings I had grabbed the endpoint from the model deployment which gives me the full url for calling the chat completion API. Because I am using the functions binding it only needs the root of the url as the endpoint setting as shown below.

Original Config

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
    "AZURE_OPENAI_ENDPOINT":"https://[mikes-ai-namespace].openai.azure.com/openai/deployments/gpt-4/chat/completions?api-version=2024-08-01-preview",
    "AZURE_OPENAI_KEY":"[Mikes KEY]",
    "CHAT_MODEL_DEPLOYMENT_NAME":"gpt-4"
  }
}

Updated Config:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
    "AZURE_OPENAI_ENDPOINT":"https://[mikes-ai-namespace].openai.azure.com",
    "AZURE_OPENAI_KEY":"[Mikes KEY]",
    "CHAT_MODEL_DEPLOYMENT_NAME":"gpt-4"
  }
}

Other useful resources

Nuget Package – https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.OpenAI

Sample – https://github.com/Azure/azure-functions-openai-extension/blob/main/samples/textcompletion/csharp-ooproc/Program.cs

Additional Info – https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/function-calling

 

Buy Me A Coffee