简体   繁体   中英

How to assign content trust policy to container registry resource azure powershell

I have created container registry as below through 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

As i know and from the resources , currently it is not available to enable via a PowerShell script. 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.

The content trust policy for the ACR is in its properties, so you need to set it in the commands. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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