Skip to content

Commit aa02526

Browse files
authored
[ACR] Troubleshooting guide (Azure#22926)
1 parent 6a25930 commit aa02526

File tree

2 files changed

+90
-22
lines changed

2 files changed

+90
-22
lines changed

sdk/containerregistry/container-registry/README.md

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ The [Azure Identity library][identity] provides easy Azure Active Directory supp
5656
```javascript
5757
const {
5858
ContainerRegistryClient,
59-
KnownContainerRegistryAudience
59+
KnownContainerRegistryAudience,
6060
} = require("@azure/container-registry");
6161
const { DefaultAzureCredential } = require("@azure/identity");
6262

6363
const endpoint = process.env.CONTAINER_REGISTRY_ENDPOINT;
6464
// Create a ContainerRegistryClient that will authenticate through Active Directory
6565
const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), {
66-
audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud
66+
audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud,
6767
});
6868
```
6969

@@ -79,7 +79,7 @@ To authenticate with a registry in a [National Cloud](https://docs.microsoft.com
7979
```javascript
8080
const {
8181
ContainerRegistryClient,
82-
KnownContainerRegistryAudience
82+
KnownContainerRegistryAudience,
8383
} = require("@azure/container-registry");
8484
const { DefaultAzureCredential, AzureAuthorityHosts } = require("@azure/identity");
8585

@@ -89,7 +89,7 @@ const client = new ContainerRegistryClient(
8989
endpoint,
9090
new DefaultAzureCredential({ authorityHost: AzureAuthorityHosts.AzureChina }),
9191
{
92-
audience: KnownContainerRegistryAudience.AzureResourceManagerChina
92+
audience: KnownContainerRegistryAudience.AzureResourceManagerChina,
9393
}
9494
);
9595
```
@@ -111,7 +111,7 @@ Iterate through the collection of repositories in the registry.
111111
```javascript
112112
const {
113113
ContainerRegistryClient,
114-
KnownContainerRegistryAudience
114+
KnownContainerRegistryAudience,
115115
} = require("@azure/container-registry");
116116
const { DefaultAzureCredential } = require("@azure/identity");
117117

@@ -120,7 +120,7 @@ async function main() {
120120
// where "myregistryname" is the actual name of your registry
121121
const endpoint = process.env.CONTAINER_REGISTRY_ENDPOINT || "<endpoint>";
122122
const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), {
123-
audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud
123+
audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud,
124124
});
125125

126126
console.log("Listing repositories");
@@ -140,7 +140,7 @@ main().catch((err) => {
140140
```javascript
141141
const {
142142
ContainerRegistryClient,
143-
KnownContainerRegistryAudience
143+
KnownContainerRegistryAudience,
144144
} = require("@azure/container-registry");
145145

146146
async function main() {
@@ -149,7 +149,7 @@ async function main() {
149149

150150
// Create a new ContainerRegistryClient for anonymous access
151151
const client = new ContainerRegistryClient(endpoint, {
152-
audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud
152+
audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud,
153153
});
154154

155155
// Obtain a RegistryArtifact object to get access to image operations
@@ -175,7 +175,7 @@ main().catch((err) => {
175175
```javascript
176176
const {
177177
ContainerRegistryClient,
178-
KnownContainerRegistryAudience
178+
KnownContainerRegistryAudience,
179179
} = require("@azure/container-registry");
180180
const { DefaultAzureCredential } = require("@azure/identity");
181181

@@ -185,7 +185,7 @@ async function main() {
185185

186186
// Create a new ContainerRegistryClient and RegistryArtifact to access image operations
187187
const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), {
188-
audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud
188+
audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud,
189189
});
190190
const image = client.getArtifact("library/hello-world", "v1");
191191

@@ -203,7 +203,7 @@ main().catch((err) => {
203203
```javascript
204204
const {
205205
ContainerRegistryClient,
206-
KnownContainerRegistryAudience
206+
KnownContainerRegistryAudience,
207207
} = require("@azure/container-registry");
208208
const { DefaultAzureCredential } = require("@azure/identity");
209209

@@ -212,7 +212,7 @@ async function main() {
212212
const endpoint = process.env.CONTAINER_REGISTRY_ENDPOINT || "<endpoint>";
213213
// Create a new ContainerRegistryClient
214214
const client = new ContainerRegistryClient(endpoint, new DefaultAzureCredential(), {
215-
audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud
215+
audience: KnownContainerRegistryAudience.AzureResourceManagerPublicCloud,
216216
});
217217

218218
// Iterate through repositories
@@ -221,7 +221,7 @@ async function main() {
221221
const repository = client.getRepository(repositoryName);
222222
// Obtain the images ordered from newest to oldest by passing the `order` option
223223
const imageManifests = repository.listManifestProperties({
224-
order: "LastUpdatedOnDescending"
224+
order: "LastUpdatedOnDescending",
225225
});
226226
const imagesToKeep = 3;
227227
let imageCount = 0;
@@ -249,15 +249,7 @@ main().catch((err) => {
249249

250250
## Troubleshooting
251251

252-
### Logging
253-
254-
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
255-
256-
```javascript
257-
const { setLogLevel } = require("@azure/logger");
258-
259-
setLogLevel("info");
260-
```
252+
For infomation about troubleshooting, refer to the [troubleshooting guide].
261253

262254
## Next steps
263255

@@ -291,3 +283,4 @@ If you'd like to contribute to this library, please read the [contributing guide
291283
[azure_sub]: https://azure.microsoft.com/free/
292284
[identity]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md
293285
[az_sdk_js]: https://github.com/Azure/azure-sdk-for-js
286+
[troubleshooting guide]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/containerregistry/container-registry/TROUBLESHOOTING.md
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Troubleshoot Azure Container Registry client library issues
2+
3+
This troubleshooting guide contains instructions to diagnose frequently encountered issues while using the Azure Container Registry client library for JavaScript and TypeScript.
4+
5+
## General Troubleshooting
6+
7+
Container registry service methods throw [`RestError`] on failure.
8+
9+
### Enable client logging
10+
11+
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
12+
13+
```javascript
14+
const { setLogLevel } = require("@azure/logger");
15+
16+
setLogLevel("info");
17+
```
18+
19+
See the [logger reference documentation][logging reference] for more information on how to configure logging.
20+
21+
## Troubleshooting authentication errors
22+
23+
### HTTP 401 Errors
24+
25+
HTTP 401 errors indicate problems authenticating. Check the exception message or logs for more information.
26+
27+
#### Anonymous access issues
28+
29+
You may see an error similar to the one below. It indicates an attempt to perform an operation that requires authentication without credentials.
30+
31+
```
32+
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required, visit https://aka.ms/acr/authorization for
33+
more information."}]}
34+
```
35+
36+
Unauthorized (anonymous) access can only be enabled for read (pull) operations such as listing repositories, getting properties or tags. Refer to [Anonymous pull access] to learn about the limitations of anonymous access.
37+
38+
### HTTP 403 Errors
39+
40+
HTTP 403 errors indicate that user is not authorized to perform a specific operation in Azure Container Registry.
41+
42+
#### Insufficient permissions
43+
44+
If you see an error similar to the one below, it means that the provided credentials do not have permission to access the registry.
45+
46+
```
47+
RestError: {"errors":[{"code":"DENIED","message":"retrieving permissions failed"}]}
48+
```
49+
50+
To resolve:
51+
52+
1. Check that the application or user that is making the request has sufficient permissions. Check [Troubleshoot registry login] for possible solutions.
53+
1. If the user or application is granted sufficient privileges to query the workspace, make sure you are authenticating as that user/application. If you are authenticating using [DefaultAzureCredential], check the logs to verify that the credential used is the one you expected. To enable logging, see the [Enable client logging] section above.
54+
55+
#### Network access issues
56+
57+
The below error indicates that public access to the Azure Container Registry is disabled or restricted. Refer to [Troubleshoot network issues with registry] for more information.
58+
59+
```
60+
RestError: {"errors":[{"code":"DENIED","message":"client with IP '<your IP address>' is not allowed access. Refer https://aka.m
61+
s/acr/firewall to grant access."}]}
62+
```
63+
64+
<!-- Links -->
65+
66+
[`resterror`]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-rest-pipeline/src/restError.ts
67+
[azure logger client library]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger
68+
[logging reference]: https://docs.microsoft.com/javascript/api/overview/azure/logger-readme
69+
[anonymous pull access]: https://docs.microsoft.com/azure/container-registry/anonymous-pull-access
70+
[troubleshoot registry login]: https://docs.microsoft.com/azure/container-registry/container-registry-troubleshoot-login
71+
[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md#authenticating-with-the-defaultazurecredential
72+
[enable client logging]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/containerregistry/container-registry/TROUBLESHOOTING.md#enable-client-logging
73+
[troubleshoot network issues with registry]: https://docs.microsoft.com/azure/container-registry/container-registry-troubleshoot-access
74+
75+
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcontainerregistry%2Fcontainer-registry%TROUBLESHOOTING.png)

0 commit comments

Comments
 (0)