Hi Rawat, Rahul,
Thanks for posting your question in Microsoft Q&A, apologize for any inconvenience caused on this.
The error indicates that the service principal you're using does not have the necessary permissions to access the API.
Here are a few steps you can take to resolve this issue:
- Verify Role Assignments: Ensure that the service principal has the necessary roles assigned. In addition to the OpenAI Contributor Role, you should also assign the
Azure AI Developer role
or theAzure AI Administrator role
. - Check Role Scope: Make sure that the role assignments are at the correct scope. The roles should be assigned directly to the Azure OpenAI resource via the Azure portal.
If the above steps do not resolve the issue, you can try the following workarounds:
- Test with Owner Role: Temporarily assign the Owner role to the service principal to test if it's a permissions issue. If the error is resolved, it confirms that the issue is related to permissions.
- API Key Authentication: If Azure RBAC is not working, consider using API key authentication. Ensure that the API keys are correct, not expired, and properly set in the WebApp Environment variable
AZURE_OPENAI_KEY
.
By following these steps, you should be able to resolve the permission issue and get your setup working locally on your MacBook.
Please feel free to click the 'Upvote' (Thumbs-up) button and 'Accept as Answer'. This helps the community by allowing others with similar queries to easily find the solution.
Cheers