Skip to content

Commit dbe3dce

Browse files
authored
update resource creation snippets (Azure#7384)
1 parent 4ca418e commit dbe3dce

File tree

3 files changed

+79
-59
lines changed

3 files changed

+79
-59
lines changed

sdk/keyvault/azure-keyvault-certificates/README.md

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,27 @@ pip install azure-keyvault-certificates
1919
```
2020

2121
### Prerequisites
22-
* An [Azure subscription][azure_sub].
23-
* Python 2.7, 3.5.3, or later to use this package.
24-
* A Key Vault. If you need to create a Key Vault, you can use the [Azure Cloud Shell][azure_cloud_shell] to create one with this Azure CLI command.
25-
Replace `<your-resource-group-name>` and `<your-key-vault-name>` with your own unique names:
26-
22+
* An [Azure subscription][azure_sub]
23+
* Python 2.7, 3.5.3, or later
24+
* A Key Vault. If you need to create one, you can use the
25+
[Azure Cloud Shell][azure_cloud_shell] to create one with these commands
26+
(replace `"my-resource-group"` and `"my-key-vault"` with your own, unique
27+
names):
28+
* (Optional) if you want a new resource group to hold the Key Vault:
29+
```sh
30+
az group create --name my-resource-group --location westus2
31+
```
32+
* Create the Key Vault:
2733
```Bash
28-
az keyvault create --resource-group <your resource group name> --name <your key vault name>
34+
az keyvault create --resource-group my-resource-group --name my-key-vault
2935
```
3036

3137
Output:
3238
```json
3339
{
3440
"id": "...",
3541
"location": "westus2",
36-
"name": "<your key vault name>",
42+
"name": "my-key-vault",
3743
"properties": {
3844
"accessPolicies": [...],
3945
"createMode": null,
@@ -46,44 +52,46 @@ pip install azure-keyvault-certificates
4652
"provisioningState": "Succeeded",
4753
"sku": { "name": "standard" },
4854
"tenantId": "...",
49-
"vaultUri": "https://<your key vault name>.vault.azure.net/"
55+
"vaultUri": "https://my-key-vault.vault.azure.net/"
5056
},
51-
"resourceGroup": "<your resource group name>",
57+
"resourceGroup": "my-resource-group",
5258
"type": "Microsoft.KeyVault/vaults"
5359
}
5460
```
5561
56-
> The `"vaultUri"` property is the `vault_url` used by `CertificateClient`.
62+
> The `"vaultUri"` property is the `vault_url` used by `CertificateClient`
5763
5864
### Authenticate the client
59-
In order to interact with a Key Vault's certificates, you'll need an instance of the [CertificateClient][certificate_client_docs]
60-
class. Creating one requires a **vault url** and
61-
**credential**. This document demonstrates using `DefaultAzureCredential` as
62-
the credential, authenticating with a service principal's client id, secret,
63-
and tenant id. Other authentication methods are supported. See the
64-
[azure-identity][azure_identity] documentation for more details.
65-
66-
#### Create a service principal
67-
Use this [Azure Cloud Shell][azure_cloud_shell] snippet to create a
68-
service principal:
69-
70-
* Create a service principal and configure its access to Azure resources:
65+
In order to interact with a Key Vault's certificates, you'll need an instance
66+
of the [CertificateClient][certificate_client_docs] class. Creating one
67+
requires a **vault url** and **credential**. This document demonstrates using
68+
`DefaultAzureCredential` as the credential, authenticating with a service
69+
principal's client id, secret, and tenant id. Other authentication methods are
70+
supported. See the [azure-identity][azure_identity] documentation for more
71+
details.
72+
73+
#### Create a service principal
74+
This [Azure Cloud Shell][azure_cloud_shell] snippet shows how to create a
75+
new service principal. Before using it, replace "your-application-name" with
76+
a more appropriate name for your service principal.
77+
78+
* Create a service principal:
7179
```Bash
72-
az ad sp create-for-rbac -n <your-application-name> --skip-assignment
80+
az ad sp create-for-rbac --name http://my-application --skip-assignment
7381
```
7482
Output:
7583
```json
7684
{
7785
"appId": "generated app id",
78-
"displayName": "your-application-name",
79-
"name": "http://your-application-name",
86+
"displayName": "my-application",
87+
"name": "http://my-application",
8088
"password": "random password",
8189
"tenant": "tenant id"
8290
}
8391
```
8492
85-
* Use the output to set **AZURE_CLIENT_ID** (appId), **AZURE_CLIENT_SECRET**
86-
(password), and **AZURE_TENANT_ID** (tenant) environment variables. The
93+
* Use the output to set **AZURE_CLIENT_ID** (appId), **AZURE_CLIENT_SECRET**
94+
(password) and **AZURE_TENANT_ID** (tenant) environment variables. The
8795
following example shows a way to do this in Bash:
8896
```Bash
8997
export AZURE_CLIENT_ID="generated app id"
@@ -93,7 +101,7 @@ following example shows a way to do this in Bash:
93101
94102
* Authorize the service principal to perform certificate operations in your Key Vault:
95103
```Bash
96-
az keyvault set-policy --name <your-key-vault-name> --spn $AZURE_CLIENT_ID --certificate-permissions backup create delete get import list purge recover restore update
104+
az keyvault set-policy --name my-key-vault --spn $AZURE_CLIENT_ID --certificate-permissions backup create delete get import list purge recover restore update
97105
```
98106
> Possible certificate permissions: backup, create, delete, deleteissuers, get, getissuers, import, list, listissuers, managecontacts, manageissuers, purge, recover, restore, setissuers, update
99107

sdk/keyvault/azure-keyvault-keys/README.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,26 @@ pip install azure-keyvault-keys
2222

2323
### Prerequisites
2424
* An [Azure subscription][azure_sub]
25-
* Python 2.7, 3.5 or later
25+
* Python 2.7, 3.5.3, or later
2626
* A Key Vault. If you need to create one, you can use the
27-
[Azure Cloud Shell][azure_cloud_shell] to create one with this command (replace
28-
`<your resource group name>` and `<your key vault name>` with your own, unique
27+
[Azure Cloud Shell][azure_cloud_shell] to create one with these commands
28+
(replace `"my-resource-group"` and `"my-key-vault"` with your own, unique
2929
names):
30+
* (Optional) if you want a new resource group to hold the Key Vault:
31+
```sh
32+
az group create --name my-resource-group --location westus2
33+
```
34+
* Create the Key Vault:
3035
```Bash
31-
az keyvault create --resource-group <your resource group name> --name <your key vault name>
36+
az keyvault create --resource-group my-resource-group --name my-key-vault
3237
```
3338

3439
Output:
3540
```json
3641
{
3742
"id": "...",
3843
"location": "westus2",
39-
"name": "<your key vault name>",
44+
"name": "my-key-vault",
4045
"properties": {
4146
"accessPolicies": [...],
4247
"createMode": null,
@@ -49,9 +54,9 @@ names):
4954
"provisioningState": "Succeeded",
5055
"sku": { "name": "standard" },
5156
"tenantId": "...",
52-
"vaultUri": "https://<your key vault name>.vault.azure.net/"
57+
"vaultUri": "https://my-key-vault.vault.azure.net/"
5358
},
54-
"resourceGroup": "<your resource group name>",
59+
"resourceGroup": "my-resource-group",
5560
"type": "Microsoft.KeyVault/vaults"
5661
}
5762
```
@@ -66,20 +71,21 @@ the credential, authenticating with a service principal's client id, secret,
6671
and tenant id. Other authentication methods are supported. See the
6772
[azure-identity][azure_identity] documentation for more details.
6873
69-
#### Create a service principal
70-
Use this [Azure Cloud Shell][azure_cloud_shell] snippet to create a
71-
service principal:
74+
#### Create a service principal
75+
This [Azure Cloud Shell][azure_cloud_shell] snippet shows how to create a
76+
new service principal. Before using it, replace "your-application-name" with
77+
a more appropriate name for your service principal.
7278
73-
* Create a service principal and configure its access to Azure resources:
79+
* Create a service principal:
7480
```Bash
75-
az ad sp create-for-rbac -n <your-application-name> --skip-assignment
81+
az ad sp create-for-rbac --name http://my-application --skip-assignment
7682
```
7783
Output:
7884
```json
7985
{
8086
"appId": "generated app id",
81-
"displayName": "your-application-name",
82-
"name": "http://your-application-name",
87+
"displayName": "my-application",
88+
"name": "http://my-application",
8389
"password": "random password",
8490
"tenant": "tenant id"
8591
}
@@ -96,7 +102,7 @@ following example shows a way to do this in Bash:
96102
97103
* Authorize the service principal to perform key operations in your Key Vault:
98104
```Bash
99-
az keyvault set-policy --name <your key vault name> --spn $AZURE_CLIENT_ID --key-permissions backup delete get list create
105+
az keyvault set-policy --name my-key-vault --spn $AZURE_CLIENT_ID --key-permissions backup delete get list create
100106
```
101107
> Possible key permissions:
102108
> - Key management: backup, delete, get, list, purge, recover, restore, create, update, import

sdk/keyvault/azure-keyvault-secrets/README.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,26 @@ pip install azure-keyvault-secrets
2222

2323
### Prerequisites
2424
* An [Azure subscription][azure_sub]
25-
* Python 2.7, 3.5 or later
25+
* Python 2.7, 3.5.3, or later
2626
* A Key Vault. If you need to create one, you can use the
27-
[Azure Cloud Shell][azure_cloud_shell] to create one with this command (replace
28-
`<your resource group name>` and `<your key vault name>` with your own, unique
27+
[Azure Cloud Shell][azure_cloud_shell] to create one with these commands
28+
(replace `"my-resource-group"` and `"my-key-vault"` with your own, unique
2929
names):
30+
* (Optional) if you want a new resource group to hold the Key Vault:
31+
```sh
32+
az group create --name my-resource-group --location westus2
33+
```
34+
* Create the Key Vault:
3035
```Bash
31-
az keyvault create --resource-group <your resource group name> --name <your key vault name>
36+
az keyvault create --resource-group my-resource-group --name my-key-vault
3237
```
3338

3439
Output:
3540
```json
3641
{
3742
"id": "...",
3843
"location": "westus2",
39-
"name": "<your key vault name>",
44+
"name": "my-key-vault",
4045
"properties": {
4146
"accessPolicies": [...],
4247
"createMode": null,
@@ -49,14 +54,14 @@ names):
4954
"provisioningState": "Succeeded",
5055
"sku": { "name": "standard" },
5156
"tenantId": "...",
52-
"vaultUri": "https://<your key vault name>.vault.azure.net/"
57+
"vaultUri": "https://my-key-vault.vault.azure.net/"
5358
},
54-
"resourceGroup": "<your resource group name>",
59+
"resourceGroup": "my-resource-group",
5560
"type": "Microsoft.KeyVault/vaults"
5661
}
5762
```
5863
59-
> The `"vaultUri"` property is the `vault_url` used by `SecretClient`.
64+
> The `"vaultUri"` property is the `vault_url` used by `SecretClient`
6065
6166
### Authenticate the client
6267
In order to interact with a Key Vault's secrets, you'll need an instance of the
@@ -66,20 +71,21 @@ the credential, authenticating with a service principal's client id, secret,
6671
and tenant id. Other authentication methods are supported. See the
6772
[azure-identity][azure_identity] documentation for more details.
6873
69-
#### Create a service principal
70-
Use this [Azure Cloud Shell][azure_cloud_shell] snippet to create a
71-
service principal:
74+
#### Create a service principal
75+
This [Azure Cloud Shell][azure_cloud_shell] snippet shows how to create a
76+
new service principal. Before using it, replace "your-application-name" with
77+
a more appropriate name for your service principal.
7278
73-
* Create a service principal and configure its access to Azure resources:
79+
* Create a service principal:
7480
```Bash
75-
az ad sp create-for-rbac -n <your-application-name> --skip-assignment
81+
az ad sp create-for-rbac --name http://my-application --skip-assignment
7682
```
7783
Output:
7884
```json
7985
{
8086
"appId": "generated app id",
81-
"displayName": "your-application-name",
82-
"name": "http://your-application-name",
87+
"displayName": "my-application",
88+
"name": "http://my-application",
8389
"password": "random password",
8490
"tenant": "tenant id"
8591
}
@@ -96,7 +102,7 @@ following example shows a way to do this in Bash:
96102
97103
* Authorize the service principal to perform key operations in your Key Vault:
98104
```Bash
99-
az keyvault set-policy --name <your key vault name> --spn $AZURE_CLIENT_ID --key-permissions backup delete get list create
105+
az keyvault set-policy --name my-key-vault --spn $AZURE_CLIENT_ID --key-permissions backup delete get list create
100106
```
101107
> Possible key permissions:
102108
> - Key management: backup, delete, get, list, purge, recover, restore, create, update, import

0 commit comments

Comments
 (0)