Skip to content

Latest commit

 

History

History
187 lines (135 loc) · 6.55 KB

AzureFoundry.md

File metadata and controls

187 lines (135 loc) · 6.55 KB

Create an Azure OpenAI Deployment in Microsoft Foundry

This guide explains how to create the Azure resources and model deployment used by CONNX Demo. Microsoft changes portal labels periodically, so consult the linked Microsoft documentation if the current portal differs slightly.

What You Need

  • An Azure account with an active subscription.
  • Permission to create or use a Microsoft Foundry resource and deploy models.
  • Permission to read the resource endpoint and an API key.
  • A region where the required OpenAI model is available and permitted by your organization.

See Microsoft's current Foundry resource quickstart for resource and role requirements.

1. Create or Open a Foundry Project

  1. Sign in to the Microsoft Foundry portal.
  2. Create a project, or open an existing project owned by your organization.
  3. When creating a project, select the correct subscription, resource group, resource name, and region.
  4. Wait for the project and its associated Foundry resource to finish provisioning.

If your organization manages Azure resources centrally, ask which existing Foundry or Azure OpenAI resource to use. Do not create a duplicate resource only to obtain another deployment.

2. Deploy an OpenAI Model

  1. In the project, open Models + endpoints.
  2. Choose Deploy model. The portal may first direct you to the model catalog.
  3. Select an OpenAI chat model available to your subscription and region.
  4. Review the deployment type, model version, capacity or quota, and content filtering options available to your organization.
  5. Enter a deployment name and create the deployment.
  6. Wait until the deployment reports a ready or successful state.

Azure API requests use the deployment name, which can differ from the underlying model name. Microsoft explains deployments in its Foundry endpoint documentation.

For example, if a model is deployed as 'gpt-5.4-mini', configure:

AZURE_OPENAI_DEPLOYMENT=gpt-5.4-mini

Do not enter the model catalog name unless it is also the deployment name you created.

3. Collect the Endpoint and API Key

Open the deployment or its associated Azure resource and locate its endpoint and keys. Depending on the current portal, these may appear under Models + endpoints, Endpoint, or Keys and Endpoint.

You need these values:

Application setting Azure value
AZURE_OPENAI_ENDPOINT Azure OpenAI resource base endpoint
AZURE_OPENAI_API_KEY API key belonging to that resource
AZURE_OPENAI_DEPLOYMENT Deployment name created above

For this application, use the Azure OpenAI base resource endpoint, such as:

https://your-resource-name.openai.azure.com/

Some newer Foundry resources display a base endpoint under services.ai.azure.com. Use the endpoint shown for the deployment's Azure OpenAI API, not a project-management URL or playground URL.

Do not include /chat/completions or /deployments/<name> in AZURE_OPENAI_ENDPOINT; the OpenAI SDK adds the API route. Microsoft lists supported endpoint forms in the Azure OpenAI API reference.

Treat the API key as a secret. Never put it in source code, documentation, screenshots, issues, or Git commits.

4. Configure CONNX Demo

From the project directory, create .env if needed:

Copy-Item .env.example .env

Set the Azure values:

AZURE_OPENAI_API_KEY=your-actual-resource-key
AZURE_OPENAI_ENDPOINT=https://your-resource-name.openai.azure.com/
AZURE_OPENAI_DEPLOYMENT=your-deployment-name
AZURE_OPENAI_API_VERSION=2024-02-15-preview
AZURE_OPENAI_MAX_COMPLETION_TOKENS=500

Keep .env local. It is ignored by this repository and must never be added forcibly to Git.

The API version above is the version currently configured by this project. Only change it when intentionally testing an API version supported by both the Azure deployment and installed OpenAI SDK.

5. Test in the Foundry Playground

Before testing this application, open the deployment's chat playground:

  1. Select the deployment.
  2. Enter a short prompt.
  3. Confirm the deployment returns a response.

This isolates Azure provisioning, quota, and content-filtering issues from the application and database configuration.

6. Verify CONNX Demo

  1. Complete the database and SECRET_KEY settings in README.md.

  2. Start the application:

    python app.py
  3. Open http://localhost:4999.

  4. Submit:

    Show a list of employees that own GREEN coloured vehicles.
    

A successful result confirms that the deployment name, endpoint, key, API version, network access, and database configuration work together.

Troubleshooting

Deployment Is Unavailable

  • Confirm the model is available in the resource's region.
  • Check subscription quota and deployment capacity.
  • Confirm you have permission to create deployments.
  • Follow your organization's approval process if Azure requires registration or administrative approval.

Missing Azure Configuration

  • Spell every AZURE_OPENAI_* variable exactly as shown.
  • Replace every placeholder copied from .env.example.
  • Restart Flask after editing .env.

Resource Not Found or 404

  • Use the deployment name, not merely the catalog model name.
  • Confirm the endpoint and deployment belong to the same Azure resource.
  • Use only the base endpoint in AZURE_OPENAI_ENDPOINT.
  • Confirm the configured API version is accepted by the deployment.

Unauthorized or 401/403

  • Confirm the API key belongs to the same resource as the endpoint.
  • Rotate the key if it may have been exposed.
  • Check whether local key authentication is disabled. This application currently expects API-key authentication, not Microsoft Entra ID.

Timeout, DNS, or Network Failure

  • Verify the endpoint hostname resolves from the machine running Flask.
  • Check proxy, firewall, private endpoint, and virtual-network rules.
  • For a private endpoint, use an approved network with the required private DNS configuration.

Security and Cost Checklist

  • Use a deployment name that identifies the application and environment.
  • Choose quota and capacity appropriate for a demo workload.
  • Configure budgets or cost alerts according to organizational policy.
  • Restrict resource access to users and applications that need it.
  • Rotate keys exposed in logs, chat, screenshots, or Git.
  • Never commit .env.