microsoft / microsoft/simplechat

Attribute error on container site start when using Cosmos Managed Identity

Open
#536 1 comment 0 reactions 1 assignee View on GitHub

@paullizer is already working on this.

Since Feb 5, 2026.

documentation
Dominant language
Python
Stars
152
Forks
116
Avg merge
7h 7m
Merged PRs (30d)
122

Description

When I configure the App Service to use the Cosmos DB Managed Identity instead of the key, I get the error "Container didn't respond to HTTP pings on port: 5000. Failing site start."

In the container logs, I see the error:
Traceback (most recent call last):
File "/app/app.py", line 2, in
from config import *
File "/app/config.py", line 163, in
cosmos_client = CosmosClient(cosmos_endpoint, credential=DefaultAzureCredential())
File "/app/venv/lib/python3.13/site-packages/azure/cosmos/cosmos_client.py", line 178, in__init__
self.client_connection = CosmosClientConnection(
url, auth=auth, consistency_level=consistency_level, connection_policy=connection_policy, **kwargs
)
File "/app/venv/lib/python3.13/site-packages/azure/cosmos/_cosmos_client_connection.py", line 230, in set_client_consistency_level
user_consistency_policy = database_account.ConsistencyPolicy

AttributeError: 'NoneType' object has no attribute 'ConsistencyPolicy'

To configure the App Service to use the Cosmos DB Managed Identity:
-Set App Service Environment variable AZURE_COSMOS_AUTHENTICATION_TYPE=managed_identity
-Remove App Service Environment variable AZURE_COSMOS_KEY
-Grant App Service User Assigned Managed Identity the role [Cosmos DB Built-in Data Contributor] on Cosmos DB

I am also using custom endpoints:
-Set App Service Environment variable AZURE_COSMOS_ENDPOINT=https://.documents.azure.:443/
-Set App Service Environment variable CUSTOM_IDENTITY_URL_VALUE=https://login.microsoftonline.
-Set App Service Environment variable CUSTOM_ISSUER_URL_ENDPOINT_VALUE=https://sts.microsoftonline.

Switching back to Cosmos DB key authentication does not generate this error.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.