azure-sdk-for-js icon indicating copy to clipboard operation
azure-sdk-for-js copied to clipboard

Fix Azure OpenAI Sample by adding the required endpoint parameter

Open Copilot opened this issue 9 months ago • 3 comments

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

  1. Added loading of environment variables from .env file using dotenv
  2. Added the endpoint parameter to the AzureOpenAI client initialization options
  3. Set up the endpoint to be loaded from the AZURE_OPENAI_ENDPOINT environment 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.

Copilot avatar May 21 '25 22:05 Copilot

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.

github-actions[bot] avatar Aug 01 '25 05:08 github-actions[bot]

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.

github-actions[bot] avatar Oct 03 '25 05:10 github-actions[bot]

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.

github-actions[bot] avatar Dec 05 '25 05:12 github-actions[bot]