microsoft / microsoft/simplechat
Attribute error on container site start when using Cosmos Managed Identity
@paullizer is already working on this.
Since Feb 5, 2026.
- 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
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.
Assessment
This issue has not been assessed yet.