简体   繁体   English

如何将内容信任策略分配给容器注册表资源 azure powershell

[英]How to assign content trust policy to container registry resource azure powershell

I have created container registry as below through powershell.我通过powershell创建了如下容器注册表。

$prop = @{
        Location          = "..."
        ResourceName      = "Resource1"
        ResourceType      = "Microsoft.ContainerRegistry/registries" 
        ResourceGroupName = "ResourceGroup.." 
        Force             = $true
        Sku               = @{"Name"="Premium"}
        }
       $registry = New-AzResource @prop"

It gets created successfully, but the content trust policy set for this is "disabled" How can i make it enabled during creation through powershell它已成功创建,但为此设置的内容信任策略已“禁用”如何在创建过程中通过 powershell 启用它

As i know and from the resources , currently it is not available to enable via a PowerShell script. 据我所知,从resources ,当前无法通过PowerShell脚本启用。 However as mentioned above in the resource. 但是,如上文资源中所述。

As a work around, If you want to do with only PowerShell, you can create a function and trigger API's from that function. 解决方法是,如果只想使用PowerShell,则可以创建一个函数并从该函数触发API。

The content trust policy for the ACR is in its properties, so you need to set it in the commands. ACR 的内容信任策略在其属性中,因此您需要在命令中进行设置。 Finally, the commands will like this:最后,命令将是这样的:

$prop = @{
    Location            ="location"
    ResourceName        ="resourceName"
    ResourceType        ="Microsoft.ContainerRegistry/registries"
    ResourceGroupName   ="groupName"
    Sku                 =@{"Name"="Premium"}
    Properties          =@{"Policies"=@{"TrustPolicy"=@{"Type"="Notary";"Status"="enabled"}}}
}
$registry = New-AzResource @prop

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM