Skip to content

Commit 68f5dd9

Browse files
committed
Revision
1 parent d15bf7e commit 68f5dd9

File tree

1 file changed

+48
-22
lines changed

1 file changed

+48
-22
lines changed

articles/key-vault/rest-error-codes.md

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ There are several different reason why a request may return 401.
2929

3030
### No authentication token attached to the request.
3131

32-
Here is an example PUT request, set the value of a secret:
32+
Here is an example PUT request, setting the value of a secret:
3333

3434
```
3535
PUT https://putreqexample.vault.azure.net//secrets/DatabaseRotatingPassword?api-version=7.0 HTTP/1.1
@@ -46,60 +46,86 @@ Content-Length: 31
4646
}
4747
```
4848

49-
The "Authorization" header is the access token that is required with every call to the Key Vault for data-plane operations. If this header is missing, then the response must be 401.
49+
The "Authorization" header is the access token that is required with every call to the Key Vault for data-plane operations. If the header is missing, then the response must be 401.
5050

5151
### The token lacks the correct resource associated with it.
5252

53-
When requesting an access token from the Azure OAUTH endpoint, a parameter called "resource" is mandatory. The value is important for the token provider because it scopes the token for its intended use. The resource for ALL tokens that want to access a Key Vault is: <https://vault.keyvault.net>. Note that there is no trailing slash on the resource.
53+
When requesting an access token from the Azure OAUTH endpoint, a parameter called "resource" is mandatory. The value is important for the token provider because it scopes the token for its intended use. The resource for **all* tokens to access a Key Vault is <https://vault.keyvault.net> (with no trailing slash).
5454

5555
### The token is expired
5656

57-
We can check the values in any access token by decoding it. Tokens are base64 encoded and there are a lot of websites that will decode it for you, such as <http://jwt.calebb.net>. This is the token from the above decoded:
57+
Tokens are base64 encoded and the values can be decoded at websites such as [http://jwt.calebb.net](http://jwt.calebb.net). Here is the above token decoded:
58+
59+
```
60+
{
61+
typ: "JWT",
62+
alg: "RS256",
63+
x5t: "nbCwW11w3XkB-xUaXwKRSLjMHGQ",
64+
kid: "nbCwW11w3XkB-xUaXwKRSLjMHGQ"
65+
}.
66+
{
67+
aud: "https://vault.azure.net",
68+
iss: "https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/",
69+
iat: 1548697513,
70+
nbf: 1548697513,
71+
exp: 1548701413,
72+
aio: "42JgYHh85jiPgdqyfTFdNStv7le/BAA=",
73+
appid: "fad7d5b3-69d6-4b48-9259-8d12124e1cf1",
74+
appidacr: "1",
75+
idp: "https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/",
76+
oid: "3975aeed-7d08-453b-b6f4-445f32698091",
77+
sub: "3975aeed-7d08-453b-b6f4-445f32698091",
78+
tid: "72f988bf-86f1-41af-91ab-2d7cd011db47",
79+
uti: "2-grhRkeIk6BeY-Ln42mAA",
80+
ver: "1.0"
81+
}.
82+
[signature]
83+
```
5884

5985
We can see many important parts in this token:
6086

6187
- aud (audience): The resource of the token. Notice that this is <https://vault.azure.net>. This token will NOT work for any resource that does not explicitly match this value, such as graph.
62-
- iat (\[issued at): The number of ticks since the start of the epoch when the token was issued.
63-
- nbf (\[not before): The number of ticks since the start of the epoch when this token becomes valid.
88+
- iat (issued at): The number of ticks since the start of the epoch when the token was issued.
89+
- nbf (not before): The number of ticks since the start of the epoch when this token becomes valid.
6490
- exp (expiration): The number of ticks since the start of the epoch when this token expires.
65-
- appid (application id): The GUID for the application id making this request.
66-
- tid (tenant id): The GUID for the tenant id of the principal making this request
91+
- appid (application ID): The GUID for the application ID making this request.
92+
- tid (tenant ID): The GUID for the tenant ID of the principal making this request
6793

6894
It is important that all of the values be properly identified in the token in order for the request to work. If everything is correct, then the request will not result in 401.
6995

7096
### Troubleshooting 401
7197

72-
401s need to be investigated from the point of generation of the token, before the request is made to the Key Vault. Generally code is being used to request the token. Once the token is received, it is passed into the Key Vault request. If the code is running locally, you can use Fiddler to capture the request/response to <https://login.microsoftonline.com>. This is what a request looks like:
98+
401s should be investigated from the point of token generation, before the request is made to the key vault. Generally code is being used to request the token. Once the token is received, it is passed into the Key Vault request. If the code is running locally, you can use Fiddler to capture the request/response to https://login.microsoftonline.com. A request looks like this:
7399

74100
```
75-
POST https://login.microsoftonline.com/<key vault tenant id>/oauth2/token HTTP/1.1
101+
POST https://login.microsoftonline.com/<key vault tenant ID>/oauth2/token HTTP/1.1
76102
Accept: application/json
77103
Content-Type: application/x-www-form-urlencoded; charset=utf-8
78104
Host: login.microsoftonline.com
79105
Content-Length: 192
80106
81-
resource=https%3A%2F%2Fvault.azure.net&client_id=<registered app id>&client_secret=<registered app secret>&client_info=1&grant_type=client_credentials
107+
resource=https%3A%2F%2Fvault.azure.net&client_id=<registered-app-ID>&client_secret=<registered-app-secret>&client_info=1&grant_type=client_credentials
82108
```
83109

84110
The following user-supplied information mush be correct:
85111

86-
- The key vault tenant id
112+
- The key vault tenant ID
87113
- Resource value set to https%3A%2F%2Fvault.azure.net (URL encoded)
88-
- Client id
114+
- Client ID
89115
- Client secret
90116

91117
Ensure the rest of the request is nearly identical.
92118

93-
If you can only get the response access token, you can decode it (as shown above) to ensure the tenant id, the client id (app id), and the resource.
119+
If you can only get the response access token, you can decode it (as shown above) to ensure the tenant ID, the client ID (app ID), and the resource.
94120

95121
## HTTP 403: Insufficient Permissions
96122

97-
HTTP 403 means that the request was authenticated (it knows the requesting identity) but the identity does not have permission to access the requested resource. There are two reasons for this:
123+
HTTP 403 means that the request was authenticated (it knows the requesting identity) but the identity does not have permission to access the requested resource. There are two causes:
98124

99125
- There is no access policy for the identity.
100126
- The IP address of the requesting resource is not whitelisted in the key vault's firewall settings.
101127

102-
HTTP 403 often occurs when the customer's application is not using the client id that the customer thinks it is. That usually means that the access policies is not correctly set up for the actual calling identity.
128+
HTTP 403 often occurs when the customer's application is not using the client ID that the customer thinks it is. That usually means that the access policies is not correctly set up for the actual calling identity.
103129

104130
### Troubleshooting 403
105131

@@ -115,25 +141,25 @@ There is a limited list of "Azure Trusted Services". Azure Web Sites are **not**
115141

116142
You must add the IP address of the Azure Web Site to the Key Vault in order for it to work.
117143

118-
If due to access policy: find the object id for the request and ensure that the object id matches the object to which the user is trying to assign the access policy. There will often be multiple objects in the AAD which have the same name, so choosing the correct one is very important. By deleting and re-adding the access policy, it is possible to see if multiple objects exist with the same name.
144+
If due to access policy: find the object ID for the request and ensure that the object ID matches the object to which the user is trying to assign the access policy. There will often be multiple objects in the AAD which have the same name, so choosing the correct one is very important. By deleting and re-adding the access policy, it is possible to see if multiple objects exist with the same name.
119145

120-
In addition: most cases of access policies DO NOT require the use of the "Authorized application" as shown in the portal. This is used for "on-behalf-of" authentication scenarios and is not generally used.
146+
In addition, most access policies do not require the use of the "Authorized application" as shown in the portal. Authorized application are used for "on-behalf-of" authentication scenarios, which are rare.
121147

122148

123149
## HTTP 429: Too Many Requests
124150

125151
Throttling occurs when the number of requests exceeds the stated maximum for the timeframe. If throttling occurs, the Key Vault's response will be HTTP 429. There are stated maximums for types of requests made. For instance: the creation of an HSM 2048-bit key is 5 requests per 10 seconds, but all other HSM transactions have a 1000 request/10 seconds limit. Therefore it is important to understand which types of calls are being made when determining the cause of throttling.
126-
In general, requests to the Key Vault are limited to 2000 requests/10 seconds. Exceptions to this rule are Key Operations and they are documented here: [Key Vault service limits](https://docs.microsoft.com/azure/key-vault/key-vault-service-limits)
152+
In general, requests to the Key Vault are limited to 2000 requests/10 seconds. Exceptions are Key Operations, as documented in [Key Vault service limits](key-vault-service-limits)
127153

128154
### Troubleshooting 429
129155
Throttling is worked around using these techniques:
130156

131157
- Reduce number of requests made to the Key Vault by determining if there are patterns to a requested resource and attempting to cache them in the calling application.
132158

133-
- When Key Vault throttling occurs, adapt the requesting code to use a exponential backoff for retrying. The algorithm is explained here: [How to throttle your app](https://docs.microsoft.com/en-us/azure/key-vault/key-vault-ovw-throttling#how-to-throttle-your-app-in-response-to-service-limits)
159+
- When Key Vault throttling occurs, adapt the requesting code to use a exponential backoff for retrying. The algorithm is explained here: [How to throttle your app](key-vault-ovw-throttling.md#how-to-throttle-your-app-in-response-to-service-limits)
134160

135-
- If the number of requests cannot be reduced by caching and timed backoff does not work, then consider splitting the keys up into multiple Key Vaults. Please note that service limits in a single subscription are limited to 5x the individual Key Vault limit. If using more than 5 Key Vaults, consideration should be given to using multiple subscriptions.
161+
- If the number of requests cannot be reduced by caching and timed backoff does not work, then consider splitting the keys up into multiple Key Vaults. The service limit for a single subscription is 5x the individual Key Vault limit. If using more than 5 Key Vaults, consideration should be given to using multiple subscriptions.
136162

137-
Detailed guidance including request to increase limits, can be find here: [Key Vault throttling guidance](https://docs.microsoft.com/en-us/azure/key-vault/key-vault-ovw-throttling)
163+
Detailed guidance including request to increase limits, can be find here: [Key Vault throttling guidance](key-vault-ovw-throttling.md)
138164

139165

0 commit comments

Comments
 (0)