简体   繁体   English

获取订阅下的所有容器注册表 - .NET Azure sdk

[英]Get all container registries under a subscription - .NET Azure sdk

Looking out for .NET SDK references to get a specified container registry or all the container registries in a resource group or the subscription.查找 .NET SDK 引用以获取指定的容器注册表或资源组或订阅中的所有容器注册表。

Need references apart from the REST API available: https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries?api-version=2019-05-01除了可用的 REST API 之外还需要参考: https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries?api-version=2019-05-01

I have seen that the operation is available through Powershell and CLI cmdlet;我已经看到该操作可通过 Powershell 和 CLI cmdlet 获得; Get-AzContainerRegistry and az acr list , but looking out for .NET SDK based library references (Azure.ResourceManager preferred) for the same. Get-AzContainerRegistryaz acr list ,但寻找基于 .NET SDK 的库引用(首选 Azure.ResourceManager)。

I have gone through https://github.com/Azure/azure-sdk-for.net , but there's no extension related to get a specific or list the container registries under a subscription.我浏览了https://github.com/Azure/azure-sdk-for.net ,但没有与获取特定或列出订阅下的容器注册表相关的扩展。

Nuget packages: Nuget 包:

// Change these as needed
ArmClient armClient = new ArmClient(new DefaultAzureCredential());
Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

// You can also get the resource group first if you know it already
// subscription.GetResourceGroups().Get("myresourcegroup");
var registyResources = subscription.GetGenericResourcesAsync("resourceType eq 'Microsoft.ContainerRegistry/registries'").AsPages();

await foreach (var resource in registyResources)
{
    var id = resource.Values.First().Id;
    Console.WriteLine($"Id: {id}");
    Console.WriteLine($"Resource Group: {id.ResourceGroupName}");
    Console.WriteLine($"Container registry name: {id.Name}");
}

You can also explore the returned resource if you need any other information.如果您需要任何其他信息,您还可以浏览返回的资源。 You can then continue with the specialized SDK for the specific Container Registry.然后,您可以继续使用特定 Container Registry 的专用 SDK

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 容器注册表 (ACR) 工件的命名策略 - Naming policies for Azure Container Registries (ACR) artefacts Azure Python Sdk 列出订阅中的所有 web 应用 - Azure Python Sdk list all web apps in Subscription Azure 存储 Python sdk - get_container_access_policy 不工作 - Azure Storage Python sdk - get_container_access_policy Not Working 在订阅中找不到 microsoft.containerregistry/registries' - microsoft.containerregistry/registries' could not be found in subscription Azure 安全中心发出高度警报“仅允许容器映像使用受信任的注册表” - Azure Security center giving high alerts "trusted registries only allowed for container images" 通过姓名获取Azure订阅 - python - Get Azure subscription through name - python 订阅中存在的所有 azure 资源的架构 - Architecture of all the azure resources present in a subscription 如何将一个订阅下的一个 azure 租户(帐户)keyvault 中的密钥共享到另一个订阅中的另一个 azure 租户(帐户)keyvault - How to share a key from one azure tenant(account) keyvault under one subscription to another azure tenant(account) keyvault in another subscription Azure Lighthouse - 获取订阅级别部署的区域 - Azure Lighthouse - Get the region for subscription level deployment Azure SDK for.Net - 两个订阅的依赖注入 - Azure SDK for .Net - dependency injection for two subscriptions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM