Skip to content

Commit 9fc0559

Browse files
committed
Reorganized article
1 parent b1325e1 commit 9fc0559

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

articles/key-vault/tutorial-net-windows-virtual-machine.md

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,36 @@ When you enable MSI for an Azure service, such as Azure Virtual Machines, Azure
4949

5050
Next, to get an access token, your code calls a local metadata service that's available on the Azure resource. To authenticate to an Azure Key Vault service, your code uses the access token that it gets from the local MSI endpoint.
5151

52-
## Log in to Azure
52+
## Set up the project
53+
54+
Before you start coding you need to create some resources, put a secret into your key vault, and set up the .NET project.
55+
56+
### Log in to Azure
5357

5458
To log in to Azure by using the Azure CLI, enter:
5559

5660
```azurecli
5761
az login
5862
```
5963

60-
## Create a resource group
64+
### Create resources and assign permissions
6165

62-
An Azure resource group is a logical container into which Azure resources are deployed and managed.
66+
#### Create a resource group
6367

64-
Create a resource group by using the [az group create](/cli/azure/group#az-group-create) command.
68+
An Azure resource group is a logical container into which Azure resources are deployed and managed. Create a resource group by using the [az group create](/cli/azure/group#az-group-create) command.
6569

66-
Then, select a resource group name and fill in the placeholder. The following example creates a resource group in the West US location:
70+
This example creates a resource group in the West US location:
6771

6872
```azurecli
6973
# To list locations: az account list-locations --output table
7074
az group create --name "<YourResourceGroupName>" --location "West US"
7175
```
7276

73-
You use your newly created resource group throughout this tutorial.
77+
Your newly created resource group will be used throughout this tutorial.
7478

75-
## Create a key vault
79+
#### Create a key vault and populate it with a secret
7680

77-
To create a key vault in the resource group that you created in the preceding step, provide the following information:
81+
Create a key vault in your resource group by providing the [az keyvault create](/cli/azure/keyvault?view=azure-cli-latest#az-keyvault-create) command with the following information:
7882

7983
* Key vault name: a string of 3 to 24 characters that can contain only numbers (0-9), letters (a-z, A-Z), and hyphens (-)
8084
* Resource group name
@@ -85,9 +89,8 @@ az keyvault create --name "<YourKeyVaultName>" --resource-group "<YourResourceGr
8589
```
8690
At this point, your Azure account is the only one that's authorized to perform operations on this new key vault.
8791

88-
## Add a secret to the key vault
92+
Now add a secret to your key vault using the [az keyvault secret set](/cli/azure/keyvault/secret?view=azure-cli-latest#az-keyvault-secret-set) command
8993

90-
We're adding a secret to help illustrate how this works. The secret might be a SQL connection string or any other information that you need to keep both secure and available to your application.
9194

9295
To create a secret in the key vault called **AppSecret**, enter the following command:
9396

@@ -97,15 +100,15 @@ az keyvault secret set --vault-name "<YourKeyVaultName>" --name "AppSecret" --va
97100

98101
This secret stores the value **MySecret**.
99102

100-
## Create a virtual machine
101-
You can create a virtual machine by using one of the following methods:
103+
#### Create a virtual machine
104+
Create a virtual machine by using one of the following methods:
102105

103106
* [The Azure CLI](https://docs.microsoft.com/azure/virtual-machines/windows/quick-create-cli)
104107
* [PowerShell](https://docs.microsoft.com/azure/virtual-machines/windows/quick-create-powershell)
105108
* [The Azure portal](https://docs.microsoft.com/azure/virtual-machines/windows/quick-create-portal)
106109

107-
## Assign an identity to the VM
108-
In this step, you create a system-assigned identity for the virtual machine by running the following command in the Azure CLI:
110+
#### Assign an identity to the VM
111+
Create a system-assigned identity for the virtual machine bwith the [az vm identity assign]/cli/azure/vm/identity?view=azure-cli-latest#az-vm-identity-assign) command:
109112

110113
```azurecli
111114
az vm identity assign --name <NameOfYourVirtualMachine> --resource-group <YourResourceGroupName>
@@ -120,17 +123,19 @@ Note the system-assigned identity that's displayed in the following code. The ou
120123
}
121124
```
122125

123-
## Assign permissions to the VM identity
124-
Now you can assign the previously created identity permissions to your key vault by running the following command:
126+
#### Assign permissions to the VM identity
127+
Assign the previously created identity permissions to your key vault with the [az keyvault set-policy](/cli/azure/keyvault?view=azure-cli-latest#az-keyvault-set-policy) command:
125128

126129
```azurecli
127130
az keyvault set-policy --name '<YourKeyVaultName>' --object-id <VMSystemAssignedIdentity> --secret-permissions get list
128131
```
129132

130-
## Log on to the virtual machine
133+
#### Log on to the virtual machine
131134

132135
To log on to the virtual machine, follow the instructions in [Connect and log on to an Azure virtual machine running Windows](https://docs.microsoft.com/azure/virtual-machines/windows/connect-logon).
133136

137+
## Set up the console app
138+
134139
## Install .NET Core
135140

136141
To install .NET Core, go to the [.NET downloads](https://www.microsoft.com/net/download) page.
@@ -141,12 +146,24 @@ Open a command prompt.
141146

142147
You can print "Hello World" to the console by running the following commands:
143148

144-
```batch
149+
```console
145150
dotnet new console -o helloworldapp
146151
cd helloworldapp
147152
dotnet run
148153
```
149154

155+
### Install the packages
156+
157+
From the console window, install the .NET packages required for this quickstart:
158+
159+
```console
160+
dotnet add package System.IO;
161+
dotnet add package System.Net;
162+
dotnet add package System.Text;
163+
dotnet add package Newtonsoft.Json;
164+
dotnet add package Newtonsoft.Json.Linq;
165+
```
166+
150167
## Edit the console app
151168

152169
Open the *Program.cs* file and add these packages:

0 commit comments

Comments
 (0)