Skip to content

Commit 4ed57be

Browse files
committed
Revisions
1 parent 93e94a6 commit 4ed57be

File tree

3 files changed

+62
-45
lines changed

3 files changed

+62
-45
lines changed

articles/key-vault/key-vault-key-rotation-log-monitoring.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,16 @@ ms.author: mbaldwin
1818

1919
After you have a key vault, you can start using it to store keys and secrets. Your applications no longer need to persist your keys or secrets, but can request them from the vault as needed. A key vault allows you to update keys and secrets without affecting the behavior of your application, which opens up a breadth of possibilities for your key and secret management.
2020

21-
>[!IMPORTANT]
22-
> The examples in this article are provided for illustration purposes only. They're not intended for production use.
21+
This article walks through how to implement a scheduled rotation of storage account keys, monitor the key vault audit logs, and raise alerts when unexpected requests are made.
2322

24-
This article walks through:
23+
You must first create a key vault using the method of your choice:
2524

26-
- An example of using Azure Key Vault to store a secret. In this article, the secret stored is the Azure storage account key accessed by an application.
27-
- How to implement a scheduled rotation of that storage account key.
28-
- How to monitor the key vault audit logs and raise alerts when unexpected requests are made.
25+
- [Set and retrieve a secret from Azure Key Vault using Azure CLI](quick-create-cli.md)
26+
- [Set and retrieve a secret from Azure Key Vault using Azure PowerShell](quick-create-powershell.md)
27+
- [Set and retrieve a secret from Azure Key Vault using Azure portal](quick-create-portal.md)
2928

30-
> [!NOTE]
31-
> This article doesn't explain in detail the initial setup of your key vault. For this information, see [What is Azure Key Vault?](key-vault-overview.md). For cross-platform command-line interface instructions, see [Manage Key Vault using the Azure CLI](key-vault-manage-with-cli2.md).
32-
33-
[!INCLUDE [updated-for-az](../../includes/updated-for-az.md)]
3429

35-
## Set up Key Vault
30+
## Store a
3631

3732
To enable an application to retrieve a secret from Key Vault, you must first create the secret and upload it to your vault.
3833

articles/key-vault/key-vault-soft-delete-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ You enable "soft-delete" to allow recovery of a deleted key vault, or objects st
4747
For an existing key vault named ContosoVault, enable soft-delete as follows.
4848

4949
```azurecli
50-
az resource update --id $(az keyvault show --name ContosoVault -o tsv | awk '{print $1}') --set properties.enableSoftDelete=true
50+
az keyvault update -n ContosoVault --enable-soft-delete true
5151
```
5252

5353
### New key vault

articles/key-vault/tutorial-rotation.md

Lines changed: 55 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,59 +12,81 @@ ms.date: 01/26/2020
1212
ms.author: mbaldwin
1313

1414
---
15-
# Single User/Password Rotation Tutorial
16-
Single User/Password Rotation Tutorial
15+
# Automate the rotation of a single user/password secret
1716

18-
The best option to authenticate to Azure services is by using Managed Identity. There are scenarios where Managed Identity is not an option and then access keys or secrets are used. In those scenarios access keys or secrets should be periodically rotated.
19-
This tutorial demonstrates how to automate periodic rotation (30 days before expiry) of secrets for databases and services with single user/password authentication. Below scenario would rotate SQL server password stored in key vault using function triggered by event grid notification.
17+
Although the best way to authenticate to Azure services is by using an [managed identity](managed-identity.md), there are some scenarios where this is not an option. In these cases, access keys or secrets are used. Access keys or secrets should be periodically rotated.
18+
19+
This tutorial demonstrates how to automate the periodic rotation of secrets for databases and services with single user/password authentication. Specifically, this scenario rotates SQL server passwords stored in key vault using a function triggered by Event Grid notification:
2020

2121
![Rotation diagram](./media/rotate1.png)
2222

23-
1. Key Vault publish near expiry event to Event Grid 30 days before expiration date
24-
1. Event Grid checks event subscriptions and calls (http post) Function App endpoint subscribed to this event
25-
1. Function App receives secret information, generates new random password and create new version for that secret with new password in Key Vault
26-
1. Function App updates SQL with new password
23+
1. Thirty days before 30 days before the expiration date of a secret, Key Vault publish the "near expiry" event to Event Grid .
24+
1. Event Grid checks the event subscriptions and, using http post, calls the Function App endpoint subscribed to this event.
25+
1. The function App receives secret information, generates new random password, and create a new version for the secret with a new password in Key Vault.
26+
1. The function App updates SQL with new password.
2727

2828
Note: There could be a lag between step 3 and 4 and during that time secret in Key Vault would not be valid to authenticate to SQL. In case of failure in any of the steps Event Grid retries for 2 hours.
2929

30-
## Infrastructure setup
31-
Before required steps for rotation are demonstrated we need initial infrastructure setup to imitate common environment.
32-
Create resource group with Key Vault, SQL Server and store admin password in Key Vault as secret.
33-
This tutorial would use pre-created Azure Resource Manager template to create components. You can find entire code here(Basic Secret Rotation Template Sample).
34-
Components List:
35-
- Key Vault
36-
- SQL Server
30+
## Setup
3731

38-
Azure Resource Manager template to create components: [Deploy](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fjlichwa%2Fazure-keyvault-basicrotation-tutorial%2Fmaster%2Farm-templates%2Finitial-setup%2Fazuredeploy.json)
39-
- Create new resource group like below
40-
- Click Purchase
32+
## Create a key vault and SQL server
4133

42-
![Purchase screen](./media/rotate2.png)
34+
Before we begin, we must create a Key Vault, create a SQL Server and database, and store the SQL Server admin password in Key Vault.
4335

44-
For simplicity you can run below deployment to create all components and configuration at once and skip to step 3:
45-
Components List:
46-
- Key Vault
47-
- SQL Server
48-
- App Service Plan
49-
- Function App
50-
- Storage Account
51-
- Web App
52-
Azure Resource Manager template to create components: [Deploy](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fjlichwa%2Fazure-keyvault-basicrotation-tutorial%2Fmaster%2Farm-templates%2Fall%2Fazuredeploy.json)
36+
This tutorial uses a pre-created Azure Resource Manager template to create components. You can find entire code here: [Basic Secret Rotation Template Sample](https://github.com/jlichwa/azure-keyvault-basicrotation-tutorial/tree/master/arm-templates).
37+
38+
1. Use the Azure Resource Manager template to create components by selecting this link: [Deploy](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fjlichwa%2Fazure-keyvault-basicrotation-tutorial%2Fmaster%2Farm-templates%2Finitial-setup%2Fazuredeploy.json)
39+
1. For "Resource Group", select "Create New" and give it the name "simplerotation".
40+
1. Select "Purchase".
41+
42+
![Create new resource group](./media/rotate2.png)
43+
44+
After completing these steps, you will have a key vault, a SQL server, and a SQL database. You can verify this in an Azure CLI terminal by running:
45+
46+
```azurecli
47+
az resource list -o table
48+
```
49+
50+
The results will look something this:
51+
52+
```console
53+
Name ResourceGroup Location Type Status
54+
----------------------- -------------------- ---------- --------------------------------- --------
55+
simplerotation-kv simplerotation eastus Microsoft.KeyVault/vaults
56+
simplerotation-sql simplerotation eastus Microsoft.Sql/servers
57+
simplerotation-sql/master simplerotation eastus Microsoft.Sql/servers/databases
58+
```
5359

5460
## Create Function App
5561

62+
You must now create a Function App with a with system managed identity, as well as the additional required components:
63+
5664
Function app requires below components and configuration:
5765
- App Service Plan
5866
- Storage Account
59-
- Function App with System Managed Identity
6067
- Access policy to access secrets in Key Vault using Function App Managed Identity
6168

62-
Azure Resource Manager template to create components:[Deploy](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fjlichwa%2Fazure-keyvault-basicrotation-tutorial%2Fmaster%2Farm-templates%2Ffunction-app%2Fazuredeploy.json)
63-
- Select resource group like below
64-
- Click Purchase
69+
Use the Azure Resource Manager template to create components by selecting this link: [Deploy](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fjlichwa%2Fazure-keyvault-basicrotation-tutorial%2Fmaster%2Farm-templates%2Ffunction-app%2Fazuredeploy.json)
70+
1. For "Resource Group", select "simplerotation".
71+
1. Select "Purchase".
6572

66-
![Purchase screen](./media/rotate3.png)
73+
![Purchase screen](./media/rotate3.png)
74+
75+
After completing the steps above, you will have a storage account, a server farm, and a Function App. You can verify this in an Azure CLI terminal by running:
76+
77+
```azurecli
78+
az resource list -o table
79+
```
6780

81+
The results will look something this:
82+
Name ResourceGroup Location Type Status
83+
----------------------- -------------------- ---------- --------------------------------- --------
84+
simplerotation-kv simplerotation eastus Microsoft.KeyVault/vaults
85+
simplerotation-sql simplerotation eastus Microsoft.Sql/servers
86+
simplerotation-sql/master simplerotation eastus Microsoft.Sql/servers/databases
87+
simplerotationstrg simplerotation eastus Microsoft.Storage/storageAccounts
88+
simplerotation-plan simplerotation eastus Microsoft.Web/serverFarms
89+
simplerotation-fn simplerotation eastus Microsoft.Web/sites
6890

6991
For information how to create Function App and using Managed Identity to access Key Vault, see [Create a function app from the Azure portal](../azure-functions/functions-create-function-app-portal.md) and [Provide Key Vault authentication with a managed identity](managed-identity.md)
7092

0 commit comments

Comments
 (0)