Fix Azure OpenAI Sample by adding the required endpoint parameter
Issue
The Azure OpenAI sample code for codeInterpreter.js and codeInterpreter.ts in the v2-beta samples was missing the required endpoint parameter. This caused the error:
Must provide one of the `baseURL` or `endpoint` arguments, or the `AZURE_OPENAI_ENDPOINT` environment variable
Changes
- Added loading of environment variables from
.envfile using dotenv - Added the
endpointparameter to the AzureOpenAI client initialization options - Set up the endpoint to be loaded from the
AZURE_OPENAI_ENDPOINTenvironment variable with a fallback to a placeholder
JavaScript Sample:
// Load the .env file if it exists
require("dotenv").config();
// Get the endpoint from the environment variable or use a placeholder
const endpoint = process.env["AZURE_OPENAI_ENDPOINT"] || "<your-azure-openai-endpoint>";
const client = new AzureOpenAI({
azureADTokenProvider,
apiVersion,
endpoint, // Specify the Azure OpenAI endpoint
});
TypeScript Sample:
// Load the .env file if it exists
import * as dotenv from "dotenv";
dotenv.config();
// Get the endpoint from the environment variable or use a placeholder
const endpoint = process.env["AZURE_OPENAI_ENDPOINT"] || "<your-azure-openai-endpoint>";
const client = new AzureOpenAI({
azureADTokenProvider,
apiVersion,
endpoint, // Specify the Azure OpenAI endpoint
});
This change ensures that the AzureOpenAI client is properly initialized with the required endpoint parameter, following the OpenAI SDK requirements.
Fixes #31995.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Hi @Copilot. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.
Hi @Copilot. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.
Hi @Copilot. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.