@@ -19,21 +19,27 @@ pip install azure-keyvault-certificates
19
19
```
20
20
21
21
### 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:
27
33
` ` ` 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
29
35
` ` `
30
36
31
37
Output:
32
38
` ` ` json
33
39
{
34
40
" id" : " ..." ,
35
41
" location" : " westus2" ,
36
- "name": "<your key vault name> ",
42
+ " name" : " my- key- vault" ,
37
43
" properties" : {
38
44
" accessPolicies" : [...],
39
45
" createMode" : null,
@@ -46,44 +52,46 @@ pip install azure-keyvault-certificates
46
52
" provisioningState" : " Succeeded" ,
47
53
" sku" : { " name" : " standard" },
48
54
" tenantId" : " ..." ,
49
- "vaultUri": "https://<your key vault name> .vault.azure.net/"
55
+ " vaultUri" : " https://my- key- vault.vault.azure.net/"
50
56
},
51
- "resourceGroup": "<your resource group name> ",
57
+ " resourceGroup" : " my- resource- group" ,
52
58
" type" : " Microsoft.KeyVault/vaults"
53
59
}
54
60
` ` `
55
61
56
- > The `"vaultUri"` property is the `vault_url` used by `CertificateClient`.
62
+ > The ` " vaultUri" ` property is the ` vault_url` used by ` CertificateClient`
57
63
58
64
# ## 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:
71
79
```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
73
81
```
74
82
Output:
75
83
```json
76
84
{
77
85
"appId": "generated app id",
78
- " displayName" : " your -application-name " ,
79
- " name" : " http://your -application-name " ,
86
+ "displayName": "my -application",
87
+ "name": "http://my -application",
80
88
"password": "random password",
81
89
"tenant": "tenant id"
82
90
}
83
91
```
84
92
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
87
95
following example shows a way to do this in Bash:
88
96
```Bash
89
97
export AZURE_CLIENT_ID="generated app id"
@@ -93,7 +101,7 @@ following example shows a way to do this in Bash:
93
101
94
102
* Authorize the service principal to perform certificate operations in your Key Vault:
95
103
```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
97
105
```
98
106
> Possible certificate permissions: backup, create, delete, deleteissuers, get, getissuers, import, list, listissuers, managecontacts, manageissuers, purge, recover, restore, setissuers, update
99
107
0 commit comments