microsoft / microsoft/openclaw-dev
bug: Cognitive Services OpenAI User role not assigned to managed identity — 401 on all chat completions
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 25
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
Summary
After a successful devclaw up / devclaw deploy, the container starts and the gateway reports ready — but every chat message fails with a 401. The container app's managed identity is never granted the Cognitive Services OpenAI User role on the Azure OpenAI resource.
Error seen in container logs
[agent/embedded] embedded run agent end: isError=true model=gpt-5.4-mini
error=LLM request failed. rawError=401 The principal `<principalId>` lacks
the required data action `Microsoft.CognitiveServices/accounts/OpenAI/
deployments/chat/completions/action` to perform
`POST /openai/v1/chat/completions` operation.
Steps to reproduce
- Complete
devclaw up(even successfully) - Open the WebChat UI — gateway shows Online, model shows
gpt-5.4-mini - Send any message
- Assistant returns
[assistant turn failed before producing content] - Container logs show 401 on every
/openai/v1/chat/completionscall
Root cause
Same pattern as the AcrPull gap. Bicep configures the container app to use AZURE_OPENAI_AUTH=managed-identity but does not create the Cognitive Services OpenAI User role assignment on the Azure OpenAI resource for the container app's principalId. The gateway has no API key to fall back to (by design), so every model call fails.
Expected behaviour
Bicep should create a Cognitive Services OpenAI User role assignment on the Azure OpenAI resource for the container app's system-assigned managed identity, with correct dependsOn so it is in place before the first request.
Manual workaround
PRINCIPAL_ID=$(az containerapp show -n <app> -g <rg> --query 'identity.principalId' -o tsv)
OPENAI_ID=$(az cognitiveservices account list -g <rg> --query '[0].id' -o tsv)
az role assignment create \
--assignee-object-id $PRINCIPAL_ID \
--assignee-principal-type ServicePrincipal \
--role "Cognitive Services OpenAI User" \
--scope $OPENAI_ID
Note: RBAC propagation takes ~90 seconds after assignment. The gateway does not need to be restarted.
Related
Same root cause as #22 (AcrPull not assigned). Both point to Bicep RBAC sequencing gaps that surface when azd up exits before full propagation.
Environment
- Region:
southindia - Restricted corporate subscription with Azure Policy assignments active
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the Bicep configuration that sets the container app's system-assigned managed identity and AZURE_OPENAI_AUTH=managed-identity; start by tracing the Azure OpenAI resource and container app dependencies. Add the Cognitive Services OpenAI User role assignment with the required sequencing, then verify that a deployed app can complete chat requests after RBAC propagation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- authorization, cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100