Hello Victor Mercado,
Welcome to Microsoft Q&A!
Please kindly note that the 403 Forbidden error usually indicates an issue with permissions or authentication. Here are some things you can verify:
- Ensure that the
apiKey
you are using is correct and has not expired. Double-check that you are using the primary key provided in the “Basic consumption info” section. - Verify that the identity you are using has the necessary permissions to access the endpoint. You might need specific roles or permissions assigned to your Azure ML instance.
- If your Azure ML workspace is configured with a private endpoint, ensure that your network settings are correctly configured. This includes DNS settings and virtual network configurations: https://learn.microsoft.com/en-us/azure/machine-learning/how-to-troubleshoot-secure-connection-workspace?view=azureml-api-2
Here’s a revised version of your code snippet with a slight adjustment to the authorization header:
// Replace this with the primary/secondary key, AMLToken, or Microsoft Entra ID token for the endpoint
const apiKey = "MY_PRIMARY_KEY";
if (!apiKey) {
throw new Exception("A key should be provided to invoke the endpoint");
}
requestHeaders.append("Authorization", `Bearer ${apiKey}`);
If the issue persists, consider reaching out to Azure Support for further assistance.
Best Regards,
Gao.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.