Skip to content

Commit d0dd9a0

Browse files
authored
Merge pull request #12 from justinyoo/console-app
Add purge to Key Vault console app
2 parents 2d1ba11 + 880c282 commit d0dd9a0

File tree

4 files changed

+37
-23
lines changed

4 files changed

+37
-23
lines changed

key-vault-console-app/Program.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <directives>
1+
// <directives>
22
using System;
33
using Azure.Identity;
44
using Azure.Security.KeyVault.Secrets;
@@ -10,6 +10,7 @@ class Program
1010
{
1111
static void Main(string[] args)
1212
{
13+
bool isSoftDeleteEnabled = true;
1314
string secretName = "mySecret";
1415

1516
// <authenticate>
@@ -48,9 +49,25 @@ static void Main(string[] args)
4849
client.StartDeleteSecret(secretName);
4950
// </deletesecret>
5051

51-
System.Threading.Thread.Sleep(5000);
52+
if (!isSoftDeleteEnabled)
53+
{
54+
System.Threading.Thread.Sleep(5000);
55+
Console.WriteLine(" done.");
56+
57+
return;
58+
}
59+
60+
System.Threading.Thread.Sleep(60000);
5261
Console.WriteLine(" done.");
5362

63+
Console.Write("Purging your secret from " + keyVaultName + " ...");
64+
65+
// <purgesecret>
66+
client.PurgeDeletedSecret(secretName);
67+
// </purgesecret>
68+
69+
System.Threading.Thread.Sleep(5000);
70+
Console.WriteLine(" done.");
5471
}
5572
}
5673
}

key-vault-console-app/akvdotnet.csproj

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.2</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Azure.Identity" Version="1.1.1" />
10+
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.0.2" />
11+
</ItemGroup>
12+
13+
</Project>

key-vault-console-app/akvdotnet.sln renamed to key-vault-console-app/key_vault_console_app.sln

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.0.28922.388
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "akvdotnet", "..\..\..\source\repos\akvdotnet\akvdotnet.csproj", "{0B0BA421-7C20-454B-9B87-0D0C70237C02}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "key_vault_console_app", "key_vault_console_app.csproj", "{6D17C04F-8BBB-4B13-A196-31BB137AF9A2}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{0B0BA421-7C20-454B-9B87-0D0C70237C02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{0B0BA421-7C20-454B-9B87-0D0C70237C02}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{0B0BA421-7C20-454B-9B87-0D0C70237C02}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{0B0BA421-7C20-454B-9B87-0D0C70237C02}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{6D17C04F-8BBB-4B13-A196-31BB137AF9A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{6D17C04F-8BBB-4B13-A196-31BB137AF9A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{6D17C04F-8BBB-4B13-A196-31BB137AF9A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{6D17C04F-8BBB-4B13-A196-31BB137AF9A2}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)