From 7bdff00084d18dcb03c59484f68f94d237795ffc Mon Sep 17 00:00:00 2001 From: ewdlop Date: Fri, 7 Jun 2024 20:59:11 -0400 Subject: [PATCH] Reconfigure some Azure Keyvault related stuff --- .gitignore | 5 ++++- ConsoleApp/ConsoleApp.csproj | 2 ++ ConsoleApp/Program.cs | 20 ++++++++++++++++++-- ConsoleApp/Properties/launchSettings.json | 7 +++++++ 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 ConsoleApp/Properties/launchSettings.json diff --git a/.gitignore b/.gitignore index 9491a2f..3a0d108 100644 --- a/.gitignore +++ b/.gitignore @@ -360,4 +360,7 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +FodyWeavers.xsd +/ConsoleApp/Properties/serviceDependencies.json +/ConsoleApp/Properties/serviceDependencies.local.json +/ConsoleApp/Properties/ServiceDependencies/local/local.arm.json \ No newline at end of file diff --git a/ConsoleApp/ConsoleApp.csproj b/ConsoleApp/ConsoleApp.csproj index 964c467..2070ce8 100644 --- a/ConsoleApp/ConsoleApp.csproj +++ b/ConsoleApp/ConsoleApp.csproj @@ -5,9 +5,11 @@ net8.0 enable enable + 4e612343-5fff-4b56-8bbe-1926c4d6f531 + diff --git a/ConsoleApp/Program.cs b/ConsoleApp/Program.cs index 222be54..6b08902 100644 --- a/ConsoleApp/Program.cs +++ b/ConsoleApp/Program.cs @@ -20,9 +20,25 @@ const string connectionStringSecret = "MyCosmosDBConnectionString"; const string databaseIdSecret = "MyCosmosDBDatabaseId"; -string azureKeyVaultEndpoint = $"https://kv-ray81081506952833917.vault.azure.net/"; -SecretClient secretClient = new SecretClient(new Uri(azureKeyVaultEndpoint), new DefaultAzureCredential(true)); +Console.WriteLine("Hello from CosmosDB Partial Update!"); + +//Azure Key Vault +//https://docs.microsoft.com/en-us/azure/key-vault/general/basic-concepts +//https://docs.microsoft.com/en-us/azure/key-vault/secrets/quick-create-net +//https://docs.microsoft.com/en-us/azure/key-vault/secrets/quick-create-python +//https://learn.microsoft.com/en-us/azure/key-vault/secrets/quick-create-node?tabs=azure-cli%2Cwindows + +Console.WriteLine("Please enter your Azure Key Vault endpoint:"); +string? azureKeyVaultEndpoint = Console.ReadLine(); + +if (string.IsNullOrWhiteSpace(azureKeyVaultEndpoint)) +{ + Console.WriteLine("Azure Key Vault endpoint is required."); + return; +} + +SecretClient secretClient = new SecretClient(new Uri(azureKeyVaultEndpoint), new DefaultAzureCredential(includeInteractiveCredentials: true)); Azure.Response connectionStringSecretResponse = await secretClient.GetSecretAsync(connectionStringSecret); Azure.Response databaseIdSecretResponse = await secretClient.GetSecretAsync(databaseIdSecret); diff --git a/ConsoleApp/Properties/launchSettings.json b/ConsoleApp/Properties/launchSettings.json new file mode 100644 index 0000000..e02c97e --- /dev/null +++ b/ConsoleApp/Properties/launchSettings.json @@ -0,0 +1,7 @@ +{ + "profiles": { + "ConsoleApp": { + "commandName": "Project" + } + } +} \ No newline at end of file