NeMo Guardrails with Azure OpenAI

Point NeMo Guardrails at an Azure OpenAI deployment with key-based authentication on the built-in azure engine, and plan the extra work Microsoft Entra ID tokens require.

On this page

How NeMo Guardrails with Azure OpenAI works in your infrastructure

Your Azure OpenAI deployment needs input and output rails in front of it, and you want those checks to run inside your own environment. NeMo Guardrails handles this with its built-in azure and azure_openai engines, which authenticate with an API key and need three core settings: the endpoint (set as parameters.azure_endpoint or base_url), azure_deployment for the deployment name, and api_version for the Azure OpenAI API version. The library runs as a Python package in your own environment or as a guardrails server you host in your cloud account or data center, so prompts, responses and API keys stay under your control. The library is licensed under Apache 2.0, and the current release is 0.25.0, which you should pin in your build and confirm against the releases page before deployment.

The key-based path is the simplest one to build. The settings are read from your config.yml, and the API key is supplied through the environment, so the secret does not need to be written into the configuration files that your team reviews. Confirm the exact api_version value your Azure OpenAI resource supports, since it must match the deployment you created. If your organization requires Microsoft Entra ID token authentication instead, the built-in engine does not cover it. You will need a manual engine: openai configuration with a token-providing setup, or the LangChain opt-in, and that choice changes which packages, environment variables and container images you maintain. Decide this before the build starts, because it affects secret handling and how the auditors reviewing the setup will read your access controls.

This page covers the NeMo Guardrails library and the guardrails server that runs it. It does not cover the NeMo Guardrails microservice, which NVIDIA has retired, so do not base your Azure OpenAI design on that container. Before you commit to a design, ask the team that will run the platform to confirm which engine, authentication method and deployment pattern they will support over the life of the system, and to test those settings against a non-production Azure OpenAI deployment.

What you need before connecting Azure OpenAI

Connecting NeMo Guardrails to Azure OpenAI depends on a handful of prerequisites that are easy to assume and costly to get wrong. The cards below cover the runtime, the Azure resource, the settings NeMo Guardrails reads, the key, the network path and where configuration and secrets live.

Python runtime version

NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13. Confirm the interpreter in the runtime image or virtual environment that will run the guardrails code, not the version on a developer laptop. A mismatch often surfaces as an installation failure, so check it before any Azure settings are tested.

Supported Python
3.11 to 3.13
PyPI package page

Azure OpenAI resource and deployment

You need an Azure OpenAI resource with a model deployed under a deployment name you choose. Record the resource endpoint and the deployment name from the Azure portal. NeMo Guardrails uses the deployment name, not the underlying model name, so a mismatch returns errors that look like authentication failures.

API version for the deployment

Confirm the API version your deployment accepts in your own Azure portal and client documentation rather than assuming a value from an older example. The version is passed to the api_version setting, and it must match what the deployment supports. Record it alongside the endpoint and deployment name so the configuration can be reviewed later.

Key stored in an environment variable

Key-based authentication on the built-in azure engine reads the key from the AZURE_OPENAI_API_KEY environment variable. Set it in the runtime environment or the secret mechanism your platform uses, and keep it out of config.yml. Decide who can rotate the key and how the runtime picks up the new value.

Network path to the Azure endpoint

The runtime that hosts NeMo Guardrails must reach the Azure OpenAI endpoint over HTTPS. Check outbound rules, proxies, DNS resolution and any private endpoint or firewall policy in your network. If the runtime is in an isolated network, confirm the path with your network team before the guardrails configuration is tested.

Where configurations and secrets live

Decide where the config.yml, Colang files and custom actions are stored, who can change them, and how changes are reviewed. Keep the API key in a secrets store rather than in the repository. Agree this before the first deployment, because moving configuration and secrets later changes the audit trail and the rollout process.

Supported LLMs docs

How to configure the azure engine step by step

This sequence takes a team from an empty folder to a NeMo Guardrails configuration that calls an Azure OpenAI deployment with key-based authentication, then proves both the Python API and the guardrails server return model responses and block a test input.

  1. Install nemoguardrails in a supported Python environment

    An engineer creates a virtual environment on Python 3.11, 3.12 or 3.13, which are the versions NeMo Guardrails 0.25.0 requires, and installs the nemoguardrails package from PyPI. Confirm the install by running the package's version command or importing the library in a Python shell without errors. Pin the version in your dependency file so every environment runs the same release.

  2. Create the configuration folder and config.yml

    Create a dedicated folder for the guardrails configuration and add a config.yml file inside it. This file names the main model, the engine and the rails that apply to it. Keep the folder in version control so changes to models and rails go through review. The step is done when the folder loads without a parsing error during the first test run.

  3. Set the azure engine and Azure OpenAI parameters

    In the models section of config.yml, set the type to the main model role, set engine to azure, and set the parameters for azure_endpoint (or base_url), azure_deployment and api_version. The deployment name must match the deployment in your Azure OpenAI resource, not the underlying model name, and the api_version must be one your resource supports. Confirm these values against your Azure portal entries, since the check that follows will fail if any of them is wrong.

  4. Provide the API key through the runtime environment

    Set AZURE_OPENAI_API_KEY in the environment where the process runs, such as the shell, a container environment or the orchestrator's secret store, rather than writing the key into config.yml or committing it to the repository. The key never appears in the configuration folder. The step is complete when a process started in that environment can read the variable and the test call in the next step authenticates.

  5. Add Colang files and any custom actions

    Add the Colang files that define input and output rails, and place any Python action files next to them in the configuration folder. Choose Colang 1.0 (the default) or 2.0 deliberately, because the two syntaxes are not interchangeable and the migration tool needs manual review. Keep rails minimal at this stage so a failure can be traced to one file. The step closes when the configuration loads with these files present and no rail errors appear in the startup log.

  6. Load the configuration and test through the Python API

    In a short Python script, load the configuration folder with the library's rails loader, then send a benign prompt and print the response. A returned model answer confirms the Azure OpenAI deployment is reachable and authenticated. Next, send an input that your input rail is designed to block and confirm the response shows the expected refusal or rail message rather than a model answer. Record both outputs as the baseline for later regression checks.

  7. Start the guardrails server and test over HTTP

    Run the guardrails server against the same configuration folder, either directly or in the server image built from the provided Dockerfile, and send the same benign and blocked prompts over the HTTP API. The benign request should return a model response and the blocked request should trigger the same rail as in the Python test. A mismatch between the two paths usually means the server is reading a different folder or environment variables, so check those first.

Which Azure settings map to which NeMo Guardrails keys

This table maps each Azure OpenAI value to the NeMo Guardrails key or environment variable that carries it, and names who supplies it. Read it as a checklist: confirm each key name against the supported LLMs page for your installed version before you deploy. The main takeaway is that key-based setup needs only the endpoint, deployment, API version and key, while Entra ID adds a separate manual configuration.

Azure valueNeMo Guardrails key or variableWho supplies it
Resource endpointparameters.azure_endpoint or base_url in config.ymlAzure administrator, from the OpenAI resource overview in the Azure portal
Deployment nameparameters.azure_deployment in config.ymlApplication team, matching the model deployment they created in the resource
API versionparameters.api_version in config.ymlApplication team, chosen from the versions Azure OpenAI supports for the deployment
API keyAZURE_OPENAI_API_KEY environment variableAzure administrator, from the resource keys page, stored in a secrets manager
Entra ID tenantNot a built-in azure engine key; needs a manual engine: openai configurationIdentity team, from the Microsoft Entra ID tenant that owns the app registration
Entra ID client and secret or certificateRead by your custom Python code that acquires the token, not by a built-in keyIdentity team, from the app registration, with credentials held outside config files
Entra ID scopePassed to your token acquisition code, then supplied as the bearer token to the engineIdentity team, confirmed against Azure OpenAI documentation for your cloud

How a request flows through the rails to Azure OpenAI

The request starts in the client application or the guardrails server, which runs input rails before any model call. The azure engine then sends the prompt to the Azure OpenAI deployment, using the API key by default, and output rails check the reply before it returns to the caller. The Azure key, or an Entra ID token if you build a manual engine for token authentication, enters at the model call and crosses the boundary into Azure. Check that credentials never appear in logs or rail outputs, and confirm where the endpoint resolves.

Request path through input and output rails to the Azure OpenAI deployment, with credentials entering at the model call.

Choosing between key-based and Entra ID authentication

The key-based path uses the built-in azure and azure_openai engines. It suits teams that want the shortest route to a working guarded deployment, that already manage Azure OpenAI keys in a secrets store, and that can accept a shared credential for the service. You configure the resource endpoint (set as parameters.azure_endpoint or base_url), the azure_deployment name, the api_version and the API key, which is supplied through the AZURE_OPENAI_API_KEY environment variable.

  • Minimal configuration: The engine block in config.yml carries the endpoint, deployment and API version, and the key stays out of the file.
  • Upgrade behavior: NVIDIA's 0.22 migration notes say existing Azure OpenAI configurations needed no change beyond setting AZURE_OPENAI_API_KEY.
  • Testing: You verify the key is injected into each container or process and that a rotated key is picked up after a restart.
  • Operations: Key rotation, storage and access review become your job, and the key grants access to the whole resource.
  • Auditability: Logs show calls made with a shared key, so attribute usage to the guardrails service identity through your own logging.

Before go-live, confirm the endpoint, deployment name and API version against your Azure OpenAI resource and your team's rotation policy.

What Microsoft Entra ID token authentication adds

The built-in azure and azure_openai engines only cover key-based authentication, so Microsoft Entra ID token authentication means your team builds the token path itself. You either configure a manual engine: openai model entry that points at the Azure OpenAI endpoint and receives a bearer token from your own code, or you use the LangChain opt-in with its extra packages and wire the Azure identity client into the model. In both cases someone must own token acquisition, caching, refresh before expiry, and injection into the client that NeMo Guardrails calls. Plan that code as part of the guardrails build, not as an afterthought to the key-based setup.

On the identity side, decide whether the runtime uses a managed identity or a service principal, and which Azure role grants it access to the Azure OpenAI resource and deployment. The aim is a secret-free runtime identity in containers: the workload obtains tokens from its platform identity, so no client secret or key sits in the image, the configuration folder or environment variables. Confirm how that identity is provided in your container platform, and check that the guardrails server, its Python actions and any logging do not print the token. Token lifetime and refresh behavior should be confirmed against current Microsoft Entra ID and Azure OpenAI documentation and your own tenant policies, since conditional access, token audiences and role names can differ by tenant.

Test token expiry deliberately. Run a load test that spans at least one token lifetime, confirm that refresh happens before a request fails, and check what the rails do when a refresh fails mid-conversation, since a blocked or errored request should not silently pass unchecked content. Exercise the failure path where the identity is revoked or the role assignment is removed, and confirm that the error is logged and surfaced to the caller. Ask Microsoft and your own identity team to confirm the current requirements for the Entra ID application, scopes and role assignments before you finalize the design.

Securing the Azure OpenAI connection

The integration adds a second place where Azure OpenAI credentials and permissions matter: the guardrails runtime and its configuration folder. The cards below cover the controls that sit around that runtime, from how the key is stored to how rail changes and blocked calls are recorded. Each one should be confirmed against your own Azure tenant and network design.

Keep the key out of config.yml

With the built-in azure engine, the API key is read from the environment rather than written into config.yml, which is the file teams copy between repositories and environments. Store the key in your secrets manager, inject it into the runtime at start, and plan rotation as a runtime restart. Confirm how your container platform delivers the variable so the value never appears in image layers, logs or shared configuration folders.

Supported LLMs docs

Scope the Azure resource to one role

The guardrails runtime only needs to send chat completion requests to one deployment. Give the key or identity access to that Azure OpenAI resource, and avoid reusing a key that also serves development notebooks or other applications. Ask Azure administrators which access model your resource uses and confirm that the permission granted is the least one the deployment accepts.

Scope the Entra ID runtime identity

If you move from key authentication to Microsoft Entra ID tokens, the integration needs a manual engine: openai configuration or the LangChain opt-in, plus your own token acquisition code. Assign the runtime identity only the Azure OpenAI role it needs, and do not let it inherit broad subscription rights. Confirm the token lifetime and refresh behavior with your identity team before production.

Restrict who can change rails

Rail behavior lives in the configuration folder, including config.yml, Colang files and any Python actions. Anyone who can edit that folder can disable a safety check or change the model the rails call. Put the folder under version control with protected branches, require review for changes, and limit write access on the running server to the release pipeline.

Log blocked and allowed calls

A guardrail is only reviewable if its decisions are recorded. Decide which events you capture, such as the input rail that fired, the rail outcome and the request identifier, and make sure the logs exclude the raw API key and, where your policy requires, the message content. Confirm the logging and tracing options in the NeMo Guardrails documentation for your release before you design retention.

Place the endpoint behind private networking

Where your Azure setup supports private endpoints for Azure OpenAI, route the guardrails runtime to the private address so prompts and completions do not cross public networks. Check DNS resolution from the runtime's subnet, egress rules on the network firewall and whether the resource's public access is disabled. Ask your Azure network team to confirm which options your subscription and region offer.

Common failures when connecting Azure OpenAI

This table lists the failures teams most often hit when pointing NeMo Guardrails at an Azure OpenAI deployment, with the likely cause and the fix for each. Read each row against your own Azure portal settings and application logs, since the exact values live in your resource, not in this page. The main takeaway is that most failures come from a mismatch between the built-in key-based engine settings and the Azure resource they point to.

SymptomLikely causeFix and what to verify
Authentication error on first callAZURE_OPENAI_API_KEY is missing, misspelled or set in a different environment than the server or processConfirm the variable is set where NeMo Guardrails actually runs, such as the shell, container or Kubernetes secret. Compare it with a key listed under Keys and Endpoint in your Azure OpenAI resource.
Resource not found or 404 on the deploymentazure_deployment does not match the deployment name in Azure, which is not always the model nameCopy the deployment name exactly from the Deployments page in Azure AI Foundry or the Azure portal, including case.
Connection fails or requests go to the wrong hostazure_endpoint or base_url points to a different resource, a wrong region, or includes a path it should notUse the endpoint base URL shown for your resource and check that it matches the resource that owns the deployment.
Unsupported API version errorapi_version is not accepted by the deployment or the resource's API generationCheck the API version your deployment accepts in Azure documentation or its request logs, then set api_version to that value and retest.
401 or token errors when using Entra IDExpecting Microsoft Entra ID to work on the built-in azure engine, which only uses key-based authenticationSwitch to a manual engine: openai configuration or the LangChain opt-in, and plan the token acquisition and refresh work. Confirm the approach with your own identity team first.
Import or module errors after enabling LangChainNEMOGUARDRAILS_LLM_FRAMEWORK=langchain is set but the required LangChain packages are not installed in the image or environmentInstall the LangChain packages your chosen integration needs in the same environment, then rebuild the container image if you run one.
Install fails or library will not import on 0.25.0Python version is outside 3.11, 3.12 or 3.13, the versions 0.25.0 requiresRun python --version in the exact runtime, such as the virtualenv, base image or CI runner, and align it before debugging configuration.

What buyers ask before connecting NeMo Guardrails to Azure OpenAI

Can our team set up NeMo Guardrails with Azure OpenAI using a key on its own?

Yes, if your engineers are comfortable with Python and YAML configuration. The built-in azure and azure_openai engines use key-based Azure OpenAI authentication, so the core setup comes down to setting parameters.azure_endpoint or base_url, azure_deployment and api_version, and providing the key through AZURE_OPENAI_API_KEY. The harder part is the rail work that follows: choosing which input and output rails to enable, writing Colang flows and testing how the rails behave on your own traffic. Your team should also confirm that the key is stored in a secrets system and that the deployment name matches the Azure resource exactly, since those are the settings most often wrong on a first run.

What drives the effort and cost of a NeMo Guardrails Azure OpenAI setup?

Effort mostly depends on how many rails you need and how much testing they require, not on the connection itself. The main cost drivers are the number of rail types in scope (input, dialog, retrieval, execution and output), whether you add safety models that you host yourself, the number of Azure OpenAI deployments you guard, and how many Azure environments (development, test, production) must be configured separately. Costs for the library are not license fees, since NeMo Guardrails is an Apache 2.0 library, but your own staff time, infrastructure and any Azure consumption are real costs. Ask any partner for a quote that lists each rail, each environment and each review step separately, so you can see what you are paying for.

When does Microsoft Entra ID token authentication change the scope of the work?

Entra ID authentication changes the scope once you want to avoid static API keys. The built-in azure engine is documented for key-based authentication, so Azure AD or token-based access needs a manual engine: openai configuration or the LangChain opt-in. That means your team must handle token acquisition, refresh, the identity used by the service, role assignment on the Azure OpenAI resource, and how the token reaches the process at runtime. Plan for this as a separate workstream with its own review by your identity team. Teams that already run managed identities or workload identity in Kubernetes often find the work manageable, while teams without that experience should budget more time.

What does our organization need to provide before the engagement starts?

Three things unblock most projects: access to the Azure environment, a test deployment and named security review contacts. Azure access should include a resource group where the guarded Azure OpenAI deployment lives, permission to create or read the application's identity and secrets, and a way to reach the endpoint from where NeMo Guardrails will run. A test deployment, separate from production, lets the team measure false positives and latency without affecting users. Security review contacts should include someone who can approve rail policies, someone who owns identity and someone who can sign off on logging and data handling. Confirm these items in the written scope before work begins.

How do testing and rail tuning affect how long the project takes?

Testing and tuning usually take longer than the connection work, because each rail must be checked against real prompts and responses. Duration grows with the number of rails, the variety of user traffic, the number of languages or topics, and how many false positives your business accepts. Expect repeated cycles where rail thresholds, Colang flows and prompts are adjusted and retested. Ask for a test plan that defines sample sets, pass criteria and the people who approve changes. NeMo Guardrails provides a Python API and a server mode, and the test approach should cover both if your applications use each one. No duration is fixed by the product itself, so treat any timeline as a function of this scope.

What recurring work follows after NeMo Guardrails goes live with Azure OpenAI?

Recurring work includes key rotation, library upgrades, Azure API version changes and rail maintenance. Keys should be rotated on a schedule your security team sets, and the rotation process should be tested in the test deployment first. Upgrades need care: NVIDIA publishes release notes and migration guides for each version, and the 0.25.0 release, for example, deprecates the LLMRails class in favor of Guardrails. Azure OpenAI configurations needed no change in the 0.22 upgrade beyond setting AZURE_OPENAI_API_KEY, but each upgrade still needs regression tests. Also plan for periodic review of rail effectiveness as your prompts and user behavior change. Ask any partner which of these items are included in a retainer and which are billed separately.

Does DeployOpen handle the Azure OpenAI connection and rail work for us?

DeployOpen plans, implements, customizes, integrates, hardens, documents and supports self-hosted open-source platforms inside your own infrastructure, and most engagements are fixed-scope with deliverables and timelines agreed in writing before work starts. For a NeMo Guardrails setup, that scope would normally cover the Azure OpenAI connection, the chosen authentication method, rail configuration, testing, documentation and handover, with Entra ID work scoped separately if you need it. DeployOpen does not publish a price list, so a quote follows from the written scope. Ongoing support, upgrades and continuous testing are available as retainers.

Which compliance evidence should we ask for from an Azure OpenAI guardrail setup?

Ask for documented configuration, access records and test results, which are the evidence most reviewers request. The configuration file showing endpoint, deployment, API version and enabled rails should be under version control. Your team should be able to show who can read and change the key or identity, how logs of blocked and allowed requests are retained, and what test sets were run before release. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports or certifications. Independent auditors and certification bodies make those determinations, so confirm early which framework your assessor will use.

How DeployOpen works on this

DeployOpen plans and builds the NeMo Guardrails configuration around your Azure OpenAI deployments, inside your own infrastructure, and hands it over with documentation your team can run. The work starts with a written scope that settles the authentication method, endpoint and deployment settings before any configuration is built.

How we scope

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
  • We confirm which Azure OpenAI resource, endpoint, deployment names and API version your guardrails will call.
  • We decide whether key-based authentication on the built-in azure engine fits your security policy, or whether Microsoft Entra ID token authentication is required.

How we build

  • We write the config.yml, Colang files and any Python actions so the azure engine settings match your deployments.
  • We move secrets such as the Azure OpenAI API key out of configuration files into your approved secret store.
  • We test each rail against your deployments, including error handling for rate limits and unavailable endpoints.

How we hand over

  • You receive the working configuration, a record of every endpoint, deployment and API version setting, and the reasons for each choice.
  • We document how to switch deployments or API versions without rewriting rails, and what to recheck after a NeMo Guardrails upgrade.
  • We walk your engineers through running the guardrails server or Python integration in the environment you control.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.
  • A retainer can cover re-testing when Azure OpenAI API versions change or when you move from key-based to Entra ID authentication.
  • Support scope, response expectations and fees are set in the written agreement, and a quote follows from that scope.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.