Considerations for Using the Azure OpenAI Services Provider

Resolved 💬 26 comments Opened Jul 12, 2025 by doggy8088 Closed Nov 2, 2025
💡 Likely answer: A maintainer (bolinfest, collaborator) responded on this thread — see the highlighted reply below.

For the latest Node.js version, I was getting source code to build codex-cli folder. Here are some notes:

  1. ~/.codex/config.json

The model must be your deployment name. It's not a "Model name".

``json
{
"model": "codex-mini",
"provider": "azure"
}
``

  1. ~/.profile

``shell
# Codex CLI
export AZURE_OPENAI_API_KEY='your-api-key'
export AZURE_BASE_URL="https://your-resource-name.openai.azure.com/openai"
``

Only o4-mini and codex-mini models able to use Responses API.

If I get codex v0.5.0 by npm install -g @openai/codex, I still can't run with Azure OpenAI. I tried everything. It just can't run.

<img width="1918" height="1207" alt="Image" src="https://github.com/user-attachments/assets/8ca096ea-212a-4c40-a0d5-64c25f01ac64" />

View original on GitHub ↗

26 Comments

kingdomseed · 1 year ago

For the Rust version, this is my toml configuration. It works with all the models listed here from my Azure deployment:

# --------------  ~/.codex/config.toml  --------------
approval_policy = "on-failure"
sandbox_mode = "workspace-write"
model_reasoning_effort = "high"
model_reasoning_summary = "detailed"

# Default settings ── used when you run plain `codex`
model_provider = "azure"
model          = "codex-mini"            # pick whatever you want as your day-to-day default

[model_providers.azure]
name         = "Azure OpenAI"
# NOTE: leave **only** the part up to /openai
base_url     = "https://YOUR_ENDPOINT.cognitiveservices.azure.com/openai"
env_key      = "AZURE_OPENAI_API_KEY"        # export this in ~/.zshrc
wire_api     = "responses"                   
query_params = { api-version = "2025-04-01-preview" }

# ----------  one profile per model  ----------
[profiles.o3]
model_provider = "azure"
model          = "o3"

[profiles.o3-pro]
model_provider = "azure"
model          = "o3-pro"

[profiles.o4-mini]
model_provider = "azure"
model          = "o4-mini"

[profiles.codex-mini]
model_provider = "azure"
model          = "codex-mini-latest"

[profiles.gpt-4.1]
model_provider = "azure"
model          = "gpt-4.1"

[profiles.model-router]
model_provider = "azure"
model          = "model-router"
# ---------------------------------------------------------------

[mcp_servers.sentry]
command = "npx"
args    = ["@sentry/mcp-server@latest"]
env     = { SENTRY_ACCESS_TOKEN = "AUTH", SENTRY_HOST       = "sentry.io" }

[mcp_servers.context7]
command = "npx"
args    = ["-y", "@upstash/context7-mcp@latest"]
# No env vars needed

[mcp_servers.sequential-thinking]
command = "npx"
args    = ["-y", "@modelcontextprotocol/server-sequential-thinking"]

[mcp_servers.filesystem]
command = "npx"
args    = ["-y", "@modelcontextprotocol/server-filesystem", "/Users/jholt/development"]

[mcp_servers.linear]
command = "npx"
args    = ["-y", "mcp-remote", "https://mcp.linear.app/sse"]
# mcp-remote turns the remote SSE feed into local stdio, which Codex supports

[mcp_servers.fetch]
command = "uvx"
args    = ["mcp-server-fetch"]

[mcp_servers.structured-workflow]
command = "npx"
args    = ["structured-workflow-mcp@latest"]
doggy8088 · 1 year ago

@kingdomseed The only different seems only the base_url.

My: https://YOUR_ENDPOINT.openai.azure.com/openai

Yours: https://YOUR_ENDPOINT.cognitiveservices.azure.com/openai

I tried both. All failed. Still the same error.

Are you install codex 0.5.0 by npm install -g @openai/codex?

<img width="771" height="129" alt="Image" src="https://github.com/user-attachments/assets/23e001b6-3b0f-4e73-b272-d68fa7fa93f2" />

doggy8088 · 1 year ago

@kingdomseed I successfully compiled the Rust source, and it runs smoothly with Azure OpenAI. Thanks. The published @openai/codex package is buggy on Azure OpenAI.

doggy8088 · 1 year ago

I've just realized that the npm install -g @openai/codex command is actually install the Rust version.

The 0.5.0 still broken for Azure OpenAI Service. If I build from Source, everything will be all right.

kingdomseed · 1 year ago
I've just realized that the npm install -g @openai/codex command is actually install the Rust version. The 0.5.0 still broken for Azure OpenAI Service. If I build from Source, everything will be all right.

I installed using homebrew (I'm running on macOS)--I'm on 0.5.0. I'm using .cognitiveservices.azure.com/openai and the wire_api=responses. Do you know if the openai.azure.com supports responses on the wire_api or only chat/compeltions?

doggy8088 · 1 year ago

I know. It is supported Responses API.

@kingdomseed I'm using Linux. Do you know why I can only access Azure OpenAI by building it from Rust source code?

kingdomseed · 1 year ago
I know. It is supported Responses API. @kingdomseed I'm using Linux. Do you know why I can only access Azure OpenAI by building it from Rust source code?

I don't--I know they had some issues with NPM for Rust version but I thought it was corrected in 0.5.0. Maybe someone else can chime in on this.

doggy8088 · 1 year ago

I upgraded to codex-cli 0.6.0.

npm install -g @openai/codex

It still failed with Azure OpenAI Service setup.

<img width="1914" height="1234" alt="Image" src="https://github.com/user-attachments/assets/38d6b97e-d17e-43be-9472-7b20ef2f5402" />

doggy8088 · 1 year ago

If I download the Linux binary, it works! 😅

cd /tmp
curl -o- -sL https://github.com/openai/codex/releases/download/rust-v0.6.0/codex-x86_64-unknown-linux-gnu.tar.gz | tar -xzf - --transform='s/codex-x86_64-unknown-linux-gnu/codex/'
./codex exec --skip-git-repo-check hi

<img width="1042" height="615" alt="Image" src="https://github.com/user-attachments/assets/2443d539-7963-4374-8ed8-66ad64dcc6a0" />

It must be something wrong with the npm package! 🔥🔥🔥

Also, the DotSlash version still has the same issue. I suspect it might be related to a Environment Variables problem.

doggy8088 · 1 year ago

I checked the DotSlash cache and the file directly download from GitHub Release for 0.6.0 version.

# Download Linux binary
curl -sSLO https://github.com/openai/codex/releases/download/$(curl -s "https://api.github.com/repos/openai/codex/releases/latest" | jq -r .tag_name)/codex-x86_64-unknown-linux-gnu.tar.gz

# Download DotSlash
curl -sSLO https://github.com/openai/codex/releases/download/$(curl -s "https://api.github.com/repos/openai/codex/releases/latest" | jq -r .tag_name)/codex

Check for .tar.gz file

Unzip it:

tar zxvf codex-x86_64-unknown-linux-gnu.tar.gz
ls -l codex-x86_64-unknown-linux-gnu

The file size is 17235880.

<img width="1240" height="210" alt="Image" src="https://github.com/user-attachments/assets/1429c7cc-edc3-43d0-b7a8-eaa9e41880c4" />

This version works!

./codex-x86_64-unknown-linux-gnu exec --skip-git-repo-check hi

<img width="1468" height="584" alt="Image" src="https://github.com/user-attachments/assets/25d71112-23fa-4643-893a-6a2f4ab2bf9e" />

Check for DotSlash

Find linux-x86_64 and get the url: <https://github.com/openai/codex/releases/download/rust-v0.6.0/codex-x86_64-unknown-linux-musl.zst>

Download it:

wget https://github.com/openai/codex/releases/download/rust-v0.6.0/codex-x86_64-unknown-linux-musl.zst

Unzip it:

zstd -d codex-x86_64-unknown-linux-musl.zst
chmod +x codex-x86_64-unknown-linux-musl
ls -l codex-x86_64-unknown-linux-musl

The file size is 22904768.

<img width="1251" height="205" alt="Image" src="https://github.com/user-attachments/assets/0a11ea09-a45e-433e-b0a6-6212d07bb8c1" />

This version not works!

./codex-x86_64-unknown-linux-musl exec --skip-git-repo-check hi

<img width="1950" height="849" alt="Image" src="https://github.com/user-attachments/assets/1b4c16af-5799-4379-8ed7-8add61217beb" />

The result

I think musl version have some issues. The gnu version is correct.

doggy8088 · 1 year ago

If the npm package include the gnu version, I think the problem will be solved as well. Please consider fix the bug or change another target.

By the way, can I choose which target I can use for npm package?

doggy8088 · 1 year ago

The @openai/codex v0.6.0 do packed with codex-x86_64-unknown-linux-musl for linux.

<img width="1452" height="486" alt="Image" src="https://github.com/user-attachments/assets/6655d527-227f-4184-a489-352bcd1c5ea6" />

Can the team switch to the GNU version?

nesdeq · 1 year ago

please for the love of god, include basic automated testing for azure so it does not break every other update.

doggy8088 · 1 year ago

Azure OpenAI is always a second-class citizen. 😑

bolinfest collaborator · 1 year ago

There was a known issue with 0.5.0 only if you used the npm version: https://github.com/openai/codex/pull/1568.

bolinfest collaborator · 1 year ago

@doggy8088

Can the team switch to the GNU version?

The GNU version inevitably doesn't work for some people because of libc differences: musl is a better "universal binary" for Linux in our experience.

doggy8088 · 10 months ago

I'm using Ubuntu 22.04.5 LTS on WSL. When I install codex by: npm i -g @openai/codex, I just can't use Azure OpenAI. I installed codex-cli 0.27.0. I tested with this version today.

This issue has been over a month. The msul version just can't connect to Azure OpenAI correctly. I don't know why. Does anyone able to look at it? @seratch

doggy8088 · 10 months ago

Install Ubuntu-24.04 distro on Windows 10 (WSL)

wsl --install -d Ubuntu-24.04

Confirm the OS version

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.3 LTS
Release:        24.04
Codename:       noble

Install NVM

curl -s -o- https://raw.githubusercontent.com/nvm-sh/nvm/$(curl -s "https://api.github.com/repos/nvm-sh/nvm/releases/latest" | jq -r .tag_name)/install.sh | bash
source ~/.bashrc
nvm install 22
nvm use 22
nvm alias default 22
node -v

Install Codex CLI

# Install msul version
npm i -g @openai/codex

# Download and install gnu version
curl -sL https://github.com/openai/codex/releases/download/rust-v0.27.0/codex-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C $NVM_DIR/versions/node/v22.19.0/lib/node_modules/@openai/codex/bin/

Setup ~/.codex/config.toml

approval_policy = "on-failure"
sandbox_mode = "workspace-write"
model_reasoning_effort = "high"
model_reasoning_summary = "detailed"

model_provider = "azure"
model          = "codex-mini"            # pick whatever you want as your day-to-day default

[model_providers.azure]
name         = "Azure OpenAI"
base_url     = "https://RESOURCENAME.openai.azure.com/openai"
env_key      = "AZURE_OPENAI_API_KEY"
wire_api     = "responses"
query_params = { api-version = "2025-04-01-preview" }

Setup AZURE_OPENAI_API_KEY environment variable for your AOAI API Key.

Try to use Codex CLI

# This will fail
codex exec 'hi'
# or call the program directly
$NVM_DIR/versions/node/v22.19.0/lib/node_modules/@openai/codex/bin/codex-x86_64-unknown-linux-musl exec 'hi'

# This will okay!
# This is only one way to use Azure OpenAI Services' endpoint right now!
$NVM_DIR/versions/node/v22.19.0/lib/node_modules/@openai/codex/bin/codex-x86_64-unknown-linux-gnu exec 'hi'

You can easily reproduce this issue now!

<img width="2364" height="1243" alt="Image" src="https://github.com/user-attachments/assets/1887b710-384f-4c59-bb08-b76bf818d7c9" />

Note: The real codex path is defined here: $NVM_BIN/codex

<img width="767" height="830" alt="Image" src="https://github.com/user-attachments/assets/5f8bdef9-51f3-48ef-a97c-c4e151c0e1ba" />

I hope this issue can be resolved. Can someone from OpenAI respond to this? Thank you!

doggy8088 · 10 months ago

More logs for you guys:

export RUST_LOG=debug
export RUST_BACKTRACE=1

codex exec --skip-git-repo-check "hello" 2>&1 | tee codex-debug.log

Logs

2025-09-01T15:36:15.325478Z  INFO codex_core::config: cwd not set, using current dir
[2025-09-01T15:36:15] OpenAI Codex v0.27.0 (research preview)
--------
workdir: /home/user/projects
model: codex-mini
provider: azure
approval: never
sandbox: workspace-write [workdir, /tmp, $TMPDIR]
reasoning effort: high
reasoning summaries: detailed
--------
[2025-09-01T15:36:15] User instructions:
hello
2025-09-01T15:36:15.325685Z DEBUG codex_core::codex: Configuring session: model=codex-mini; provider=ModelProviderInfo { name: "Azure OpenAI", base_url: Some("https://RESOURCE-NAME.openai.azure.com/openai"), env_key: Some("AZURE_OPENAI_API_KEY"), env_key_instructions: None, wire_api: Responses, query_params: Some({"api-version": "2025-04-01-preview"}), http_headers: None, env_http_headers: None, request_max_retries: None, stream_max_retries: None, stream_idle_timeout_ms: None, requires_openai_auth: false }
2025-09-01T15:36:15.345446Z DEBUG codex_core::codex: Recording items for conversation: [Message { id: None, role: "user", content: [InputText { text: "<environment_context>\n  <cwd>/home/user/projects</cwd>\n  <approval_policy>never</approval_policy>\n  <sandbox_mode>workspace-write</sandbox_mode>\n  <network_access>restricted</network_access>\n</environment_context>" }] }]
2025-09-01T15:36:15.345613Z  INFO codex_exec: Codex initialized with event: SessionConfiguredEvent { session_id: dc9dd2b7-cdc6-4fcc-b104-cdfaa375bd1e, model: "codex-mini", history_log_id: 67842, history_entry_count: 6 }
2025-09-01T15:36:15.345697Z  INFO codex_exec: Sent prompt with event ID: 0
2025-09-01T15:36:15.345803Z DEBUG codex_core::codex: Submission sub=Submission { id: "0", op: UserInput { items: [Text { text: "hello" }] } }
2025-09-01T15:36:15.346064Z DEBUG codex_core::codex: Recording items for conversation: [Message { id: None, role: "user", content: [InputText { text: "hello" }] }]
2025-09-01T15:36:15.346117Z DEBUG codex_core::codex: Recording items for conversation: []
2025-09-01T15:36:15.346174Z DEBUG codex_exec: Received event: Event { id: "0", msg: TaskStarted(TaskStartedEvent { model_context_window: Some(400000) }) }
2025-09-01T15:36:15.357268Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:15.588344Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:16.031426Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:16.800738Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:18.557081Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:18.560012Z  WARN codex_core::codex: stream disconnected - retrying turn (1/5 in 202ms)...
2025-09-01T15:36:18.560069Z DEBUG codex_exec: Received event: Event { id: "0", msg: StreamError(StreamErrorEvent { message: "stream error: error sending request for url (https://RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 1/5 in 202ms…" }) }
[2025-09-01T15:36:18] stream error: error sending request for url (https://RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 1/5 in 202ms…
2025-09-01T15:36:18.775255Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:18.992241Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:19.406458Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:20.276173Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:21.925268Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:21.950920Z  WARN codex_core::codex: stream disconnected - retrying turn (2/5 in 421ms)...
2025-09-01T15:36:21.950979Z DEBUG codex_exec: Received event: Event { id: "0", msg: StreamError(StreamErrorEvent { message: "stream error: error sending request for url (https://RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 2/5 in 421ms…" }) }
[2025-09-01T15:36:21] stream error: error sending request for url (https://RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 2/5 in 421ms…
2025-09-01T15:36:22.383416Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:22.611980Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:23.026564Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:23.819306Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:25.480610Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:25.493885Z  WARN codex_core::codex: stream disconnected - retrying turn (3/5 in 877ms)...
2025-09-01T15:36:25.493958Z DEBUG codex_exec: Received event: Event { id: "0", msg: StreamError(StreamErrorEvent { message: "stream error: error sending request for url (https://RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 3/5 in 877ms…" }) }
[2025-09-01T15:36:25] stream error: error sending request for url (https://RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 3/5 in 877ms…
2025-09-01T15:36:26.382750Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:26.608897Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:26.998827Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:27.831189Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:29.537317Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:29.556606Z  WARN codex_core::codex: stream disconnected - retrying turn (4/5 in 1.72s)...
2025-09-01T15:36:29.556680Z DEBUG codex_exec: Received event: Event { id: "0", msg: StreamError(StreamErrorEvent { message: "stream error: error sending request for url (https://RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 4/5 in 1.72s…" }) }
[2025-09-01T15:36:29] stream error: error sending request for url (https://RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 4/5 in 1.72s…
2025-09-01T15:36:31.288882Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:31.561566Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:31.960954Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:32.706973Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:34.409315Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:34.412131Z  WARN codex_core::codex: stream disconnected - retrying turn (5/5 in 3.304s)...
2025-09-01T15:36:34.412190Z DEBUG codex_exec: Received event: Event { id: "0", msg: StreamError(StreamErrorEvent { message: "stream error: error sending request for url (https://RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 5/5 in 3.304s…" }) }
[2025-09-01T15:36:34] stream error: error sending request for url (https://RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-04-01-preview); retrying 5/5 in 3.304s…
2025-09-01T15:36:37.727958Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:37.946574Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:38.337773Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:39.108895Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:40.780967Z DEBUG reqwest::connect: starting new connection: https://RESOURCE-NAME.openai.azure.com/
2025-09-01T15:36:40.796834Z  INFO codex_core::codex: Turn error: error sending request for url (https://RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-04-01-preview)
2025-09-01T15:36:40.796890Z DEBUG codex_exec: Received event: Event { id: "0", msg: Error(ErrorEvent { message: "error sending request for url (https://RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-04-01-preview)" }) }
2025-09-01T15:36:40.796969Z DEBUG codex_exec: Received event: Event { id: "0", msg: TaskComplete(TaskCompleteEvent { last_agent_message: None }) }
[2025-09-01T15:36:40] ERROR: error sending request for url (https://RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-04-01-preview)
2025-09-01T15:36:40.797081Z DEBUG codex_core::codex: Submission sub=Submission { id: "1", op: Shutdown }
2025-09-01T15:36:40.797140Z  INFO codex_core::codex: Shutting down Codex instance
2025-09-01T15:36:40.797188Z DEBUG codex_core::codex: Agent loop exited
2025-09-01T15:36:40.798550Z  INFO codex_core::codex: interrupt received: abort current task, if any
2025-09-01T15:36:40.798600Z DEBUG codex_exec: Received event: Event { id: "1", msg: ShutdownComplete }
2025-09-01T15:36:40.798625Z  INFO codex_exec: Received shutdown event, exiting event loop.

I checked TLS handshake and certificates. It's all okay.

openssl s_client -connect your-resource-name.openai.azure.com:443 -servername your-resource-name.openai.azure.com

openssl s_client -connect your-resource-name.openai.azure.com:443 -showcerts

openssl s_client -connect your-resource-name.openai.azure.com:443 -tls1_3
openssl s_client -connect your-resource-name.openai.azure.com:443 -tls1_2
doggy8088 · 10 months ago

I finally confirmed that is a DNS resolve issue from msul implementation.

Programs built with musl libc cannot reliably resolve Azure OpenAI (AOAI) service endpoints due to fundamental limitations in musl's DNS resolver implementation. This issue stems from musl's inability to handle complex DNS queries that exceed UDP packet size limitations, which are common with Azure's sophisticated DNS infrastructure.

Here is the sample DNS query for AOAI endpoint:

$ dig test.openai.azure.com

; <<>> DiG 9.18.30-0ubuntu0.24.04.2-Ubuntu <<>> test.openai.azure.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1218
;; flags: qr rd ad; QUERY: 1, ANSWER: 7, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;test.openai.azure.com.         IN      A

;; ANSWER SECTION:
test.openai.azure.com.  0       IN      CNAME   eastus.api.cognitive.microsoft.com.
eastus.api.cognitive.microsoft.com. 0 IN CNAME  cognitiveuseprod.trafficmanager.net.
cognitiveuseprod.trafficmanager.net. 0 IN CNAME cognitiveuseprod.azure-api.net.
cognitiveuseprod.azure-api.net. 0 IN    CNAME   apimgmttmsxrvtifzqdtqhxmfmfanqbnjviisx1axz0alfmmew.trafficmanager.net.
apimgmttmsxrvtifzqdtqhxmfmfanqbnjviisx1axz0alfmmew.trafficmanager.net. 0 IN CNAME cognitiveuseprod-eastus-01.regional.azure-api.net.
cognitiveuseprod-eastus-01.regional.azure-api.net. 0 IN CNAME apid69e4f0cd7984aa8a89d9d59fb140df1wjcqcmgrfkzhbxquwhytr.eastus.cloudapp.azure.com.
apid69e4f0cd7984aa8a89d9d59fb140df1wjcqcmgrfkzhbxquwhytr.eastus.cloudapp.azure.com. 0 IN A 20.232.91.180

;; Query time: 26 msec
;; SERVER: 172.20.240.1#53(172.20.240.1) (UDP)
;; WHEN: Tue Sep 02 01:03:30 CST 2025
;; MSG SIZE  rcvd: 758

When using the msul build, it will unable to handle this issue. I don't know how to fix it.

Workaround

To work around the issue, you can add a statically mapped DNS record to the /etc/hosts file.

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateHosts = false
127.0.0.1       localhost
<feff>
127.0.0.1       localhost

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

# Add this line below. Make sure the IP is correct.
20.232.91.180    test.openai.azure.com
jakeatmsft · 9 months ago

Here is a snippet that can be added to the ~.bashrc to automatically perform the etc/hosts modification, :

usage:
vi ~.bashrc

change the last line to your azure openai domain and insert code to the bottom:

# Function to resolve domain and add to /etc/hosts
add_domain_to_hosts() {
    local domain="$1"
    local ip=$(nslookup "$domain" | awk '/^Address: / { print $2 }' | tail -n1)

    if [[ -z "$ip" ]]; then
        echo "❌ Failed to resolve IP for $domain"
        return 1
    fi

    if ! grep -q "$domain" /etc/hosts; then
        echo "✅ Adding $domain with IP $ip to /etc/hosts"
        echo "$ip    $domain" | sudo tee -a /etc/hosts > /dev/null
    else
        echo "ℹ️ $domain already exists in /etc/hosts"
    fi
}

# Example usage:
add_domain_to_hosts example.com
doggy8088 · 9 months ago

I'm one-liner.

DOMAIN="RESOURCE-NAME.openai.azure.com"; sudo sed -i "/$DOMAIN/d" /etc/hosts && ip=$(dig +short $DOMAIN | grep -v '^$' | tail -n1) && [ -n "$ip" ] && echo "$ip $DOMAIN" | sudo tee -a /etc/hosts
etraut-openai contributor · 8 months ago

Thanks for all the discussion on this topic. I'm going to close this bug at this point because it's not clear that there's anything actionable. If there's anything specific that you'd like to see in terms of bug fixes, documentation improvements, or enhancements related to the Azure OpenAI service provider, please file new issues so we can prioritize and track them.

doggy8088 · 8 months ago

Hi @etraut-openai

I conducted numerous tests and provided a workaround. It's evident that actions can be taken, as the issue appears to be related to DNS. You can either update the README.md or address the issues in Codex CLI. These are viable solutions.

I spent a considerable amount of time addressing the issue and eventually discovered a workaround. I sincerely hope the Codex CLI can be improved. The Codex CLI is an open source software. If no one in the OpenAI understands what I am doing, we can discuss this issue rather than directly closing it. I am very disappointed with this behavior.

nesdeq · 8 months ago

How is this in any way completed/closeable?

Thanks for all the discussion on this topic. I'm going to close this bug at this point because it's not clear that there's anything actionable. If there's anything specific that you'd like to see in terms of bug fixes, documentation improvements, or enhancements related to the Azure OpenAI service provider, please file new issues so we can prioritize and track them.
etraut-openai contributor · 8 months ago

This issue was opened prior to the rewrite of Codex in Rust. The code base has changed significantly since then. This is also a very broad issue, and the conversation has covered a lot of different areas. Issues like this tend to languish and not get attention from the codex team because they're so broad. My goal is to ensure that the top-priority issues that are affecting codex users are getting the appropriate attention.

@doggy8088, thanks for your work looking into the DNS issue. I've created a fresh issue here specific to this issue. This should help focus the attention on the DNS issue in particular. Feel free to add any corrections or additions that you think would be helpful. It looks like this DNS issue is the primary issue affecting Azure OpenAI users, based on upvotes/reactions.

If there are other specific issues related to the Azure OpenAI endpoint, let's make sure that there are targeted bug reports for those issues. This will help ensure that they get attention. Thanks!

Incidentally, I just merged a bug fix submitted by @tombl that should improve rate limit behaviors when using the Azure OpenAI endpoint. That fix will be included in the next CLI release.