【问题标题】:How To Set Azure Container Instance Managed Service Identity Arguments With .Net Fluent SDK如何使用 .Net Fluent SDK 设置 Azure 容器实例托管服务标识参数
【发布时间】:2019-04-23 03:17:38
【问题描述】:

使用azure-cli创建Azure容器实例,我可以指定一个托管标识的资源id作为--assigned-identity的参数

Managed Service Identity Arguments
    --assign-identity                : Space-separated list of assigned identities. Assigned
                                       identities are either user assigned identities (resource IDs)
                                       and / or the system assigned identity ('[system]'). See
                                       examples for more info.

我尝试对 .Net Fluent Management SDK 做同样的事情,但我看不到这样做的方法。

谢谢!

【问题讨论】:

    标签: azure azure-sdk-.net azure-container-instances azure-fluent-api


    【解决方案1】:

    我认为你可能是对的。我也尝试查看 Azure Management Libraries for .NET 的源代码,但找不到任何有助于使用系统分配或用户分配标识进行创建的方法或帮助程序。

    在虚拟机的情况下支持类似的功能。 Source code

    public VirtualMachineImpl WithExistingUserAssignedManagedServiceIdentity(IIdentity identity)
    {
        this.virtualMachineMsiHelper.WithExistingExternalManagedServiceIdentity(identity);
        return this;
    }
    

    我本来希望在属于ContainerInstance 的类中看到类似的方法,例如ContainerGroupImpl,但我没有。

    免责声明:如您所见,我这样说是基于手动搜索而不是基于官方文档,所以我可能会遗漏一些东西。

    可能的替代方案

    如果您有兴趣从基于 .NET/C# 的代码中执行此操作(因为您正在寻找 .NET SDK),一种替代方法可能是使用直接 REST API。

    Container Groups - Create or Update

    PUT https://management.azure.com/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1?api-version=2018-10-01
    

    您可以指定要在正文中使用的身份

    "identity": {
        "type": "SystemAssigned, UserAssigned",
        "userAssignedIdentities": {
          "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {}
        }
    

    Full for REST API call example here

    【讨论】:

    • 感谢您的信息!我也尝试过查看文档和源代码,但找不到。改用 REST API 应该可以解决我的问题。
    猜你喜欢
    • 2018-06-03
    • 2019-12-22
    • 2023-04-05
    • 2020-08-29
    • 1970-01-01
    • 2022-12-19
    • 2020-08-10
    • 2022-06-13
    • 2018-09-05
    相关资源
    最近更新 更多