Skip to content

Commit cc67a35

Browse files
authored
Merge pull request #79444 from msmbaldwin/akvqsfix
Reorganized article
2 parents d015f1b + 40de533 commit cc67a35

File tree

2 files changed

+40
-23
lines changed

2 files changed

+40
-23
lines changed

articles/key-vault/media/MSI.png

24.4 KB
Loading

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

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,34 @@ 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+
## Create resources and assign permissions
5353

54-
To log in to Azure by using the Azure CLI, enter:
54+
Before you start coding you need to create some resources, put a secret into your key vault, and assign permissions.
55+
56+
### Sign in to Azure
57+
58+
To sign in to Azure by using the Azure CLI, enter:
5559

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

60-
## Create a resource group
61-
62-
An Azure resource group is a logical container into which Azure resources are deployed and managed.
64+
### Create a resource group
6365

64-
Create a resource group by using the [az group create](/cli/azure/group#az-group-create) command.
66+
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.
6567

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

6870
```azurecli
6971
# To list locations: az account list-locations --output table
7072
az group create --name "<YourResourceGroupName>" --location "West US"
7173
```
7274

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

75-
## Create a key vault
77+
### Create a key vault and populate it with a secret
7678

77-
To create a key vault in the resource group that you created in the preceding step, provide the following information:
79+
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:
7880

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

88-
## Add a secret to the key vault
90+
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
8991

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.
9192

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

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

9899
This secret stores the value **MySecret**.
99100

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

103104
* [The Azure CLI](https://docs.microsoft.com/azure/virtual-machines/windows/quick-create-cli)
104105
* [PowerShell](https://docs.microsoft.com/azure/virtual-machines/windows/quick-create-powershell)
105106
* [The Azure portal](https://docs.microsoft.com/azure/virtual-machines/windows/quick-create-portal)
106107

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:
108+
### Assign an identity to the VM
109+
Create a system-assigned identity for the virtual machine with the [az vm identity assign](/cli/azure/vm/identity?view=azure-cli-latest#az-vm-identity-assign) command:
109110

110111
```azurecli
111112
az vm identity assign --name <NameOfYourVirtualMachine> --resource-group <YourResourceGroupName>
@@ -120,33 +121,49 @@ Note the system-assigned identity that's displayed in the following code. The ou
120121
}
121122
```
122123

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:
124+
### Assign permissions to the VM identity
125+
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:
125126

126127
```azurecli
127128
az keyvault set-policy --name '<YourKeyVaultName>' --object-id <VMSystemAssignedIdentity> --secret-permissions get list
128129
```
129130

130-
## Log on to the virtual machine
131+
### Sign in to the virtual machine
132+
133+
To sign in to the virtual machine, follow the instructions in [Connect and sign in to an Azure virtual machine running Windows](https://docs.microsoft.com/azure/virtual-machines/windows/connect-logon).
134+
135+
## Set up the console app
131136

132-
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).
137+
Create a console app and install the required packages using the `dotnet` command.
133138

134-
## Install .NET Core
139+
### Install .NET Core
135140

136141
To install .NET Core, go to the [.NET downloads](https://www.microsoft.com/net/download) page.
137142

138-
## Create and run a sample .NET app
143+
### Create and run a sample .NET app
139144

140145
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)