Dify with Azure OpenAI Service

Connect a self-hosted Dify to Azure OpenAI deployments through the Azure OpenAI Service model provider plugin, with deployment names, regional endpoints, private networking and per-environment keys planned before go-live. DeployOpen implements and verifies the connection in your infrastructure.

On this page

How Dify with Azure OpenAI Service works for regulated teams

If your team already runs self-hosted Dify and wants Azure OpenAI deployments as its LLM and embedding provider, the supported route is the Azure OpenAI Service model provider plugin published by langgenius on the Dify Marketplace. You install it into your own Dify instance, then register your Azure resource, endpoint and deployments in the console. Dify itself stays in your infrastructure, so prompts, workflow state, knowledge base content and conversation logs are stored where you put them, and the traffic that leaves your network is the traffic to the Azure endpoint you configure. The plugin is a connector, not a hosted service, so the controls around it (who can add providers, which keys are used, where requests are routed) remain yours to design.

Dify is released under the Dify Open Source License, a modified Apache License 2.0. For a regulated team the practical points are narrow but real: the license forbids using the source code to run a multi-tenant environment (one tenant being one workspace) without written authorization, and it forbids removing or modifying the logo or copyright information in the console. A single internal deployment serving one organization is the ordinary case, but if you plan to host Dify for several business units as separate tenants or for external customers, confirm the position with Dify before you build the architecture. Confirm the current license text in the LICENSE file of the repository, since the terms govern the deployment, not this page.

What stays in your control depends on how you set up the connection. Store each Azure OpenAI API key in your secrets store or Dify's model provider settings with a clear owner, and keep development and production resources separate so a test workflow cannot spend production quota. Choose the Azure region deliberately, because the endpoint region determines where inference happens, and record that choice in your data flow documentation. Decide whether Azure traffic reaches the endpoint over public addresses or private networking, and verify the outbound path from the Dify api and worker containers. Confirm with Azure and with your own environment which deployment, networking and key-management options are available in your subscription before you commit to a design.

What you need before connecting Dify to Azure OpenAI

Connecting Dify to Azure OpenAI is only as clean as the foundation under it. The Dify deployment, the Azure subscription, the network path between Dify and the Azure endpoint, and the people who own keys and approvals each need to be settled before any model is registered. The cards below cover what to have in place and what to confirm with Azure and your own environment first.

Dify deployment baseline

The Docker Compose path needs Docker Compose 2.24.0 or later, at least 2 CPU cores and 4 GB of RAM. The stack starts the api, worker, web and plugin daemon alongside PostgreSQL, Redis, Weaviate, Nginx, a code sandbox and an SSRF proxy. Confirm that the host meets these minimums with headroom for your expected knowledge base indexing load, since the worker does the embedding calls to Azure.

Docker Compose docs

Azure OpenAI resources and deployments

Confirm which Azure OpenAI resources and model deployments your team is allowed to use for chat and for embeddings. Quotas, model availability and regional support change over time, so check them in your Azure subscription and with your Azure account team rather than relying on any list in this guide. Record the resource name and the deployment name for each model you plan to register.

Subscription and approval ownership

Name who may create or change Azure OpenAI resources, who may request new model deployments, and who approves the models that Dify apps can call. In regulated settings these decisions usually sit with the cloud platform team and the security or model risk function, not the Dify builders. Write the approval path down before the first deployment is registered.

Network path from api and worker

Both the Dify api, which serves chat and workflow calls, and the worker, which runs indexing and embedding jobs, must reach the Azure endpoint. Map the route from each container through your egress controls, any proxy, and the SSRF proxy that Dify uses for outbound requests. Confirm with your network team whether the endpoint will be reached over public internet or a private network path before you configure the provider.

Key storage and rotation

Decide where the Azure OpenAI API key lives, who can read it, and how it is rotated. Dify stores provider credentials in its database encrypted with the platform secret key, so the SECRET_KEY value and the database backups must be protected together. Plan separate keys for development and production so that a test workspace never holds production credentials.

Environment variables reference

Data residency and region choice

Choose the Azure region and endpoint with your data residency rules in mind, because prompts, retrieved context and embeddings are sent to the endpoint you configure. Confirm with your compliance team which regions are approved and whether a deployment in that region offers the models you need. Also confirm that the Dify plugin version you install supports the endpoint format your region uses.

Configure the Azure OpenAI provider in Dify step by step

This sequence takes a Dify workspace from an empty model list to a tested Azure OpenAI connection, with chat and embedding deployments registered, verified in the region you intended, and set as workspace defaults. Each step ends with a check you can record as evidence.

  1. Confirm the plugin source and environment plan

    Before any configuration, the platform owner confirms which Azure OpenAI resource, region and deployments each Dify environment (development, staging, production) will use, and records who holds the keys. Install the Azure OpenAI Service model provider plugin published by langgenius from the Dify Marketplace, then confirm it appears in the workspace's model provider list for the correct environment only. Done when the plugin is listed in that environment and the team has a written note of the intended region for each environment.

  2. Install the plugin from the Dify Marketplace

    An administrator opens the Dify Marketplace entry for the Azure OpenAI Service model provider and installs it into the target instance. Check the plugin's publisher and version against what your security team approved, since plugins run inside your deployment and the plugin daemon handles their traffic. Done when the provider appears in the model provider settings of that instance and no other environment has been changed.

  3. Enter the endpoint and API key for each environment

    In the provider settings, the administrator enters the Azure OpenAI endpoint for the resource in the intended region and an API key issued for that resource, using separate resources or keys for development and production where your policy requires it. Store the key only through Dify's credential fields and do not paste it into workflow prompts or exported DSL files. Done when the provider saves without a validation error and the endpoint hostname shows the region you recorded in step one.

  4. Add each deployment by its deployment name

    Add each chat and embedding model as a model entry using the deployment name you created in the Azure portal, not the underlying model family name, since Azure routes requests by deployment. Record which deployment maps to which model so later upgrades or replacements are traceable. Done when every intended deployment appears in the model list with its deployment name and a status that shows it was accepted.

  5. Enable chat and embedding types separately

    Register the chat deployment and the embedding deployment as distinct model types, so a chat model cannot be selected for knowledge base indexing and an embedding model cannot be used for completions. Confirm the model type on each entry before saving. Done when the chat model appears only in LLM selectors and the embedding model appears only in knowledge base embedding selectors.

  6. Test a completion and an embedding call

    Run a short test prompt against the chat deployment and a short text against the embedding deployment from the Dify interface. Check that both return a response, then open the Dify logs for those requests to confirm the model, deployment and workspace match what you configured. Done when both calls succeed and the log entries show the expected deployment name, and when the network path for the test call (through any private endpoint or proxy) matches your design.

  7. Verify the region and record the evidence

    Confirm from the endpoint configuration, the Azure resource details and the request path that the test traffic reached the regional endpoint you planned, and keep a dated record of the endpoint, deployment names, plugin version and test results for the environment. This record is the evidence a security or compliance reviewer will ask for when checking data residency. Done when the reviewer can trace a test request from the Dify log to the intended Azure region.

  8. Confirm the workspace default models

    In the workspace model settings, set the default chat and embedding models to the Azure deployments you tested, then open a sample app and knowledge base to confirm they inherit those defaults. Changing an embedding default later affects new indexing, so record the decision. Done when a new app and a new knowledge base both pick up the intended Azure models without manual selection.

Deployment names, model names and endpoints in Dify

This table maps each Azure OpenAI identifier to the Dify field where it is entered, so the team can trace a model selection back to a specific Azure resource and deployment. Read it as a checklist for setup and for change control: any Azure-side rename or replacement must be matched on the Dify side before apps are updated. The main takeaway is that Dify binds to the deployment name, not to the model, so deployment changes are an application change.

Azure OpenAI elementWhat it identifiesWhere it appears in DifyRisk when it changes
Resource nameThe Azure OpenAI resource that holds the deployments and sits in one subscription and regionProvider credentials and endpoint settings in the Azure OpenAI provider pluginMoving or recreating the resource requires new endpoint and key values in every environment
Regional endpointThe URL of the resource, which fixes the Azure region that serves requestsEndpoint field in the provider configurationChanging region can move data processing outside the region your residency review approved
Deployment nameThe name you assign in Azure when you deploy a model to the resourceModel entry name and the value apps select when calling the modelRenaming or deleting the deployment breaks every app and workflow that points to the old name
Underlying model nameThe model family that the deployment runs, such as a chat or embedding modelModel name and model type attributes on the model entryMismatched model type can cause embedding or chat calls to fail or return unexpected output
Model versionThe specific model revision bound to the deploymentModel entry metadata, recorded for review and change trackingVersion updates can change output behavior, so re-test prompts and evaluations after any change
API versionThe Azure REST API version used for requestsProvider configuration field for the API versionRetiring or changing the API version can break calls even when the deployment is unchanged
Workspace default modelThe model that apps fall back to when no model is chosenWorkspace default settings for reasoning and embedding modelsChanging the default silently moves apps that never named a model to the new deployment

Keeping development, staging and production keys apart

The strongest separation starts in Azure, not in Dify. Each environment should point at its own Azure OpenAI resource, or at least its own deployments, so that a key issued for development cannot call production capacity, and so that quota, content filter settings and logging can differ by environment. Dify stores whatever key it is given, so the boundary you draw in Azure is the boundary that holds if Dify configuration is copied in error. Ask your Azure administrator to confirm how resources, deployments and key access are scoped in your subscription, and whether your policy requires separate subscriptions for production.

  • Separate resources per environment: Development, staging and production each get their own Azure OpenAI resource where your governance allows it.
  • Separate deployments per model: Deployment names inside each resource should match the environment, so a configuration mistake shows up as a visible name mismatch.
  • Distinct keys or identities: Issue a different key or managed identity to each resource so revoking one does not affect the others.
  • Matching content filter and quota settings: Confirm that production filter and capacity settings are set deliberately rather than inherited from a test resource.
  • Naming convention: Encode the environment in resource and deployment names so reviewers can verify scope quickly.

Before go-live, confirm with your Azure team which key rotation method and access policy apply to each resource.

How a Dify request reaches an Azure OpenAI deployment

A user or app call enters the Dify api, which hands model work to the worker and sends the outbound request through the SSRF proxy to the Azure OpenAI regional endpoint. The response returns through the same path into Dify. The metadata database, vector store and key storage sit on the trust boundary, so check which of them the request can reach, which credentials sit in Dify, and whether the proxy path to the Azure endpoint is private where your network design requires it.

Request path from caller through Dify to an Azure OpenAI deployment, with trust boundaries marked.

Securing the Azure OpenAI connection in Dify

The Azure OpenAI connection is a credential, a network path and a set of permissions that sit outside Dify's own controls. The cards below cover where the key lives, who can change it, how traffic leaves the Dify host, and which logs prove what happened on both sides.

Key storage and rotation

Store the Azure OpenAI key in your secrets manager or a Key Vault, and inject it into Dify only through the mechanism your deployment uses, never in a DSL export or a shared note. Ask the Dify provider screen who can view saved keys, and plan a rotation runbook that updates the key in every environment at once. Confirm how the SECRET_KEY setting interacts with stored credentials before you change anything, because the Dify environment reference notes that changing it after deployment logs out all users. Keep one key per environment.

Environment variables

Least-privilege Azure role assignment

Grant the Dify host's identity only the Azure role needed to call the deployment, scoped to the specific Azure OpenAI resource rather than the subscription or resource group. Separate the identity used for inference from any identity that can manage deployments, quotas or keys. Confirm with Microsoft's current role documentation which built-in roles cover inference calls in your tenant, since role names and scopes change over time.

Private endpoints and DNS

If the Azure OpenAI resource is reachable only over a private endpoint, the Dify api and worker containers must resolve the resource name to the private IP address. Verify name resolution from inside the Dify containers, not only from the host, because Docker's resolver can differ. Ask your network team to confirm that public network access is disabled for the resource and that the regional endpoint you chose matches your data residency commitment.

SSRF_PROXY behavior for outbound calls

Outbound model calls from Dify pass through the SSRF proxy configured by the SSRF_PROXY settings, which the environment reference describes as blocking internal and private IP ranges. A private endpoint address is itself a private IP, so test a live call after any proxy change and confirm the route works as intended. Do not disable or bypass the proxy to make a connection succeed. Instead, document an explicit, reviewed exception if one is truly needed.

Environment variables

Restricting who manages model providers

Decide which Dify accounts may add, edit or delete the Azure OpenAI provider and its keys. In Community edition, workspace roles are the main control, so keep administrator membership small and review it on a schedule. Dify Enterprise adds SSO and multi-workspace management, which gives you more room to separate provider administration from app building. Confirm what your edition's role model can and cannot restrict before you rely on it.

Community edition limit
1 workspace

Audit logging on both sides

Azure side: enable diagnostic logging for the Azure OpenAI resource and confirm where the logs are stored and how long your policy keeps them. Dify side: record who changed provider settings and which apps call the model, and confirm what the Dify logs contain and how long they persist in your deployment. Match timestamps and the deployment name across both logs so an investigation can trace one request end to end.

Choosing a regional endpoint for data residency

The region of the Azure OpenAI resource decides where prompts and completions are processed, so residency decisions start with that resource and its contract terms, not with the location of the Dify host. A Dify server in one country can still send every prompt to a deployment in another region, so the reader should record the region of each Azure OpenAI resource that Dify will call and treat that record as the residency fact. Confirm with the current Azure OpenAI documentation which regions offer the model families and deployment types the team needs, because availability varies and a model that is missing from the preferred region may push the design toward a different endpoint.

Ask the compliance team to confirm which data handling terms apply to the subscription, including where data is stored at rest, whether any processing leaves the chosen region and how abuse monitoring and retention are handled. These terms come from the Azure agreement and product documentation, not from Dify, and they should be filed with the design record before any production key is issued. Note that the Dify Marketplace plugin only sends the endpoint and key you configure, so the region choice is made in Azure and in the Dify provider settings together, and both should match the approved record.

Plan for knowledge base content as well as chat traffic. Embedding calls for knowledge bases send document chunks and user queries to the embedding deployment's endpoint, so an embedding deployment in a different region from the chat deployment creates a second data path that must be approved on its own. Check that every deployment used by a workflow, including rerank or any moderation step, sits in an approved region, and verify the endpoint values in each Dify model provider entry against the records before go-live.

Why Dify cannot reach Azure OpenAI and how to fix it

This table lists the failures teams hit most often when Dify calls an Azure OpenAI deployment, with the likely cause and the fix for each. Check the rows in order: a Dify model entry, the Azure resource, and the network path between them are usually where the fault sits. Most failures trace to a setting that looks correct in one place but does not match the Azure resource it points to.

SymptomLikely causeFix
Model call returns a not-found errorDeployment name in Dify does not match the deployment name in the Azure OpenAI resource. Dify expects the deployment name, not the underlying model name.Copy the deployment name from the Azure resource's deployments view and enter that exact value in the Dify model settings.
Authentication or version error on requestsAPI version in Dify does not match a version the deployment supports, or the field was left at an older default.Confirm the API version with the Azure OpenAI documentation for your resource and set the same value in Dify.
Connection times out or endpoint is refusedEndpoint URL points to the wrong region or to a resource in another region than the one where the deployment lives.Use the endpoint shown on the resource's overview page for the region that hosts the deployment, and keep it in the region your data residency rules allow.
Authentication fails only in one environmentAPI key was copied from a development or test resource into a production Dify workspace, or the reverse.Store one key per environment in Dify, pair each key with its own endpoint, and confirm the key belongs to the resource named in the endpoint.
Host name does not resolve from the Dify containersPrivate endpoint is configured but the private DNS zone is not linked to the network where Dify runs, so the public name or no name is returned.Link the private DNS zone to the Dify virtual network, then test name resolution from inside the api container before changing Dify settings.
Request blocked before it leaves DifyThe SSRF proxy blocks outbound requests to private IP ranges, and the Azure private endpoint resolves to a private address.Confirm the SSRF_PROXY settings in the environment reference and allow the specific private endpoint address through the proxy, keeping the allowlist as narrow as possible.
Embedding or chat call fails with a model-type errorAn embedding deployment was registered as a chat model, or the reverse, so the request shape does not match.Register each deployment under the model type it serves, then test chat and embedding calls separately from the Dify model test function.
Calls work for a while, then stop after a key changeAzure key was rotated or regenerated, and Dify still holds the old value.Update the key in Dify for the affected workspace, then run a test call. Plan rotation as a Dify settings change, not only an Azure change.

Questions buyers ask about Dify and Azure OpenAI

What drives the effort and cost of connecting Dify to Azure OpenAI?

The main drivers are how many environments need their own Azure OpenAI connection, how the networking is set up, how many deployments and model families are wired in, and how keys are governed. Each environment adds a separate endpoint, deployment map, key set and test pass, so a single development setup costs far less to connect than a development, staging and production chain across two regions. Networking is often the largest variable, because private endpoints and DNS changes need approval from the network team before any test can pass. Ask any partner to price these four items separately in the written scope.

Which parts of an Azure OpenAI connection are one-time work and which recur?

The one-time work covers designing the deployment map, setting up the Azure resources and private networking, registering the chat and embedding deployments in Dify, and testing each workflow and knowledge base against them. Recurring work covers rotating keys, adding deployments when models are retired or replaced, reviewing the provider plugin after Dify releases, and checking that regional endpoints still match your data residency rules. Dify minor releases arrive roughly monthly, according to the langgenius/dify releases page, so plan a recurring check of the plugin and configuration on that cadence. Ask for both lists in a quote so the ongoing cost is visible.

How long does a typical Azure OpenAI connection take?

The duration depends on scope: the number of environments, whether private networking must be built or only reviewed, how many deployments are connected, and how quickly approvals arrive from your Azure and network teams. A single environment with public endpoints and one chat deployment is a much smaller job than a regulated multi-environment setup with private endpoints and embedding models. No timeline is set here because none is supplied for this work. Ask for a schedule in the written scope and list which approvals it depends on.

What must our team provide before work starts on an Azure OpenAI connection?

You need to provide Azure access with rights to view and manage Azure OpenAI resources, the deployments that already exist or are planned, and a named owner for each environment's keys. Your network team must approve any private endpoint, DNS and outbound routing changes, and your security team should confirm which Azure region and data residency rules apply. You also need a Dify host where the work can run, inside infrastructure you control. Agreeing these items early avoids the most common delays in scope planning.

Can our own engineers connect Dify to Azure OpenAI without outside help?

Yes, a team that already runs Docker Compose or Kubernetes and manages Azure resources can complete the basic connection using the Dify Marketplace provider plugin and Azure's own documentation. The harder parts are deployment name mapping across environments, private networking, key governance and a repeatable test pass for each change. Teams without those skills in-house often choose a partner for the design and first build, then operate the result themselves. Whichever path you take, document the deployment map and key owners so the setup survives staff changes.

Does the Dify Community edition support this, or do we need Enterprise?

The Community edition is free and limited to a single workspace, and it can connect to Azure OpenAI through the provider plugin on the Dify Marketplace. Dify Enterprise, which is custom priced according to the Dify pricing page, adds SSO, multiple workspaces, advanced security, a commercial license and professional support. If you run separate workspaces per business unit or need centrally managed provider credentials, Enterprise matters for this work. Confirm the license terms with Dify before using Community for an internal regulated workload.

How do the Dify Open Source License terms affect a multi-tenant use of Azure OpenAI?

The Dify Open Source License is a modified Apache License 2.0 that forbids operating the source code as a multi-tenant environment without written authorization, where one tenant is one workspace. Connecting Azure OpenAI does not change that rule, but a setup that serves several business units or customers from separate workspaces needs a license review first. Keep the logo and copyright information in the Dify console intact, as the license also requires. Have your legal team read the LICENSE file before finalizing the design.

How DeployOpen scopes and delivers this integration

DeployOpen plans, implements, documents and supports self-hosted open-source platforms inside your own cloud accounts, data centers or air-gapped networks. For Dify with Azure OpenAI Service, that means agreeing in writing which Azure OpenAI deployments, regions and network paths the integration will use before any configuration begins.

How we scope

  • Inventory the Azure OpenAI deployments, model families and regions your teams need for chat and embedding models.
  • Record which Dify environments (development, staging, production) need separate keys and which workspaces will use each provider.
  • Agree the private networking, Key Vault and logging expectations in a written scope before work starts.
  • Engagements are fixed-scope, with scope, deliverables and timelines confirmed in writing before work begins.

How we build

  • Configure the Azure OpenAI model provider plugin in Dify, mapping each deployment name to the model it serves.
  • Set regional endpoints and private network routes so model traffic follows the data residency rules you have documented.
  • Store Azure credentials per environment and confirm Dify secret handling, including SECRET_KEY and encryption settings, is in place.
  • Test prompts, embeddings and failure paths in each environment, and record the results as evidence for your reviewers.

How we hand over

  • Deliver a configuration record covering deployment names, endpoints, key owners, network paths and rotation steps.
  • Document the upgrade and rollback steps for the Dify plugin and the Dify release line you run.
  • Walk your platform, security and compliance teams through the setup and the evidence they can review.
  • Provide the runbook for adding a new Azure OpenAI deployment without weakening the existing controls.

How we support

  • Offer ongoing support, upgrades and continuous testing as a retainer, scoped in writing.
  • Recheck the integration after Dify minor releases and Azure OpenAI model retirements that affect your deployments.
  • Retest key rotation, endpoint changes and network rules when your Azure environment changes.
  • Confirm retainer scope, response expectations and any SLA terms with DeployOpen before signing.

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.