Skip to content

Fix audience issue in container sample#20821

Closed
lambertpan wants to merge 1 commit intoAzure:mainfrom
lambertpan:Fix_audience_issue_in_container_sample
Closed

Fix audience issue in container sample#20821
lambertpan wants to merge 1 commit intoAzure:mainfrom
lambertpan:Fix_audience_issue_in_container_sample

Conversation

@lambertpan
Copy link

audience is required by ContainerRegistryClient(), however this part is missing from the /sdk/containerregistry/azure-containerregistry/samples, so added them.

@ghost ghost added Container Registry customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Sep 24, 2021
@ghost
Copy link

ghost commented Sep 24, 2021

Thank you for your contribution lambertpan! We will review the pull request and get back to you soon.

@ghost
Copy link

ghost commented Sep 24, 2021

CLA assistant check
All CLA requirements met.

@YalinLi0312
Copy link

Hi @lambertpan, thanks for pointing it out. I have a PR about ACR sample updates, it includes the fix of "audience" issue. Thanks!

@lambertpan
Copy link
Author

Thanks, I close this PR.

@lambertpan lambertpan closed this Sep 29, 2021
@adrien-barret
Copy link

@lambertpan is it released ?
seems it's now working if it is.

test sample:

from azure.identity import DefaultAzureCredential
from azure.mgmt.containerregistry import ContainerRegistryManagementClient
from azure.mgmt.resource import ResourceManagementClient
from azure.containerregistry import ContainerRegistryClient
import os

SUBSCRIPTION_ID = os.environ.get("SUBSCRIPTION_ID", None)
GROUP_NAME = "ARG_OPP_DEV_Main"
REGISTRY = "myRegistryName"



# Create client
# For other authentication approaches, please see: https://pypi.org/project/azure-identity/
resource_client = ResourceManagementClient(
    credential=DefaultAzureCredential(),
    subscription_id=SUBSCRIPTION_ID
)
registry_client = ContainerRegistryManagementClient(
    credential=DefaultAzureCredential(),
    subscription_id=SUBSCRIPTION_ID
)

# Get registries
registries = registry_client.registries.get(
    GROUP_NAME,
    REGISTRY
)
print("Get registries:\n{}".format(registries))

account_url = "https://" + REGISTRY + ".azurecr.io"
client = ContainerRegistryClient(account_url, DefaultAzureCredential())
manifest = client.list_manifest_properties()

for repository in client.list_repository_names():
    print(repository)

azure.mgmt.containerregistry import auth is working but not the client for ContainerRegistryClient

python-script/venv/lib/python3.9/site-packages/azure/containerregistry/_container_registry_client.py", line 52, in __init__
    raise ValueError("The argument audience must be set to initialize ContainerRegistryClient.")
ValueError: The argument audience must be set to initialize ContainerRegistryClient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Container Registry customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants