You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/key-vault/rest-error-codes.md
+48-22Lines changed: 48 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ There are several different reason why a request may return 401.
29
29
30
30
### No authentication token attached to the request.
31
31
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:
33
33
34
34
```
35
35
PUT https://putreqexample.vault.azure.net//secrets/DatabaseRotatingPassword?api-version=7.0 HTTP/1.1
@@ -46,60 +46,86 @@ Content-Length: 31
46
46
}
47
47
```
48
48
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.
50
50
51
51
### The token lacks the correct resource associated with it.
52
52
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).
54
54
55
55
### The token is expired
56
56
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:
- 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.
64
90
- 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
67
93
68
94
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.
69
95
70
96
### Troubleshooting 401
71
97
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:
73
99
74
100
```
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
The following user-supplied information mush be correct:
85
111
86
-
- The key vault tenant id
112
+
- The key vault tenant ID
87
113
- Resource value set to https%3A%2F%2Fvault.azure.net (URL encoded)
88
-
- Client id
114
+
- Client ID
89
115
- Client secret
90
116
91
117
Ensure the rest of the request is nearly identical.
92
118
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.
94
120
95
121
## HTTP 403: Insufficient Permissions
96
122
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:
98
124
99
125
- There is no access policy for the identity.
100
126
- The IP address of the requesting resource is not whitelisted in the key vault's firewall settings.
101
127
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.
103
129
104
130
### Troubleshooting 403
105
131
@@ -115,25 +141,25 @@ There is a limited list of "Azure Trusted Services". Azure Web Sites are **not**
115
141
116
142
You must add the IP address of the Azure Web Site to the Key Vault in order for it to work.
117
143
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.
119
145
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.
121
147
122
148
123
149
## HTTP 429: Too Many Requests
124
150
125
151
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)
127
153
128
154
### Troubleshooting 429
129
155
Throttling is worked around using these techniques:
130
156
131
157
- 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.
132
158
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)
134
160
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.
136
162
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)
0 commit comments