diff --git a/dotnet/001-connect-passwordless/Program.cs b/dotnet/001-connect-passwordless/connect.cs similarity index 92% rename from dotnet/001-connect-passwordless/Program.cs rename to dotnet/001-connect-passwordless/connect.cs index 186f8b4..c2df42f 100644 --- a/dotnet/001-connect-passwordless/Program.cs +++ b/dotnet/001-connect-passwordless/connect.cs @@ -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 @@ -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\" \"\""); + ?? throw new InvalidOperationException("COSMOS_ENDPOINT is not configured. Run: dotnet user-secrets set --file connect.cs \"COSMOS_ENDPOINT\" \"\""); var credential = new DefaultAzureCredential(); var client = new CosmosClient(endpoint, credential); diff --git a/dotnet/001-connect-passwordless/readme.md b/dotnet/001-connect-passwordless/readme.md index 76c3a84..9b3e630 100644 --- a/dotnet/001-connect-passwordless/readme.md +++ b/dotnet/001-connect-passwordless/readme.md @@ -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://.documents.azure.com:443/" +dotnet user-secrets set --file connect.cs "COSMOS_ENDPOINT" "https://.documents.azure.com:443/" ``` ### 2. Log in with Azure CLI @@ -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.