Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#:package Azure.Identity@1.13.2
#:package Microsoft.Azure.Cosmos@3.47.0
#:package Microsoft.Azure.Cosmos@3.*
#:package Newtonsoft.Json@13.*
#:package Microsoft.Extensions.Configuration.UserSecrets@10.*
#:property UserSecretsId=azurecosmosdb-samples-dotnet-001-connect-passwordless

Expand All @@ -12,7 +13,7 @@
.Build();

string endpoint = configuration["COSMOS_ENDPOINT"]
?? throw new InvalidOperationException("COSMOS_ENDPOINT is not configured. Run: dotnet user-secrets set --file Program.cs \"COSMOS_ENDPOINT\" \"<your-endpoint>\"");
?? throw new InvalidOperationException("COSMOS_ENDPOINT is not configured. Run: dotnet user-secrets set --file connect.cs \"COSMOS_ENDPOINT\" \"<your-endpoint>\"");

var credential = new DefaultAzureCredential();
var client = new CosmosClient(endpoint, credential);
Expand Down
4 changes: 2 additions & 2 deletions dotnet/001-connect-passwordless/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ az cosmosdb sql role assignment create \
### 1. Set your endpoint using user secrets

```shell
dotnet user-secrets set --file Program.cs "COSMOS_ENDPOINT" "https://<your-account>.documents.azure.com:443/"
dotnet user-secrets set --file connect.cs "COSMOS_ENDPOINT" "https://<your-account>.documents.azure.com:443/"
```

### 2. Log in with Azure CLI
Expand All @@ -41,7 +41,7 @@ az login
### 3. Run the sample

```shell
dotnet run Program.cs
dotnet run connect.cs
```

`DefaultAzureCredential` automatically uses your Azure CLI login locally. In production (Azure App Service, Azure Functions, Azure Container Apps, etc.) it uses the managed identity assigned to the resource — no code changes needed.
Expand Down
Loading