我不想为每个容器应用程序定义环境变量,因此我更愿意克隆一个已设置变量的容器应用程序。
参考文档,没有克隆功能。
我已经使用以下 PowerShell cmdlet 成功模仿了“克隆”功能,请注意,这在我的情况下有效,并且可能需要根据您要从中“复制”的容器应用程序上的配置进行修改。
Install-Module Az.App, Az.Accounts
Connect-AzAccount
$SubscriptionId = "my-sub-id"
$ContainerAppName = "myContainerApp"
$ResourceGroupName = "myRG"
$ContainerApp = Get-AzContainerApp -Name $ContainerAppName -ResourceGroupName $ResourceGroupName -SubscriptionId $SubscriptionId
$Location = $ContainerApp.Location
$UserAssignedIdentity = @{$($ContainerApp.IdentityUserAssignedIdentity.Keys | Out-String -Stream) = @{}}
$ContainerApp.Configuration.IngressCustomDomain = @()
New-AzContainerApp -Name "$ContainerAppName-clone" -ResourceGroupName $ResourceGroupName -Location $Location -Configuration $ContainerApp.Configuration `
-EnvironmentId $ContainerApp.EnvironmentId -ScaleMaxReplica 1 -ScaleMinReplica 0 -TemplateContainer $ContainerApp.TemplateContainer `
-IdentityType UserAssigned -IdentityUserAssignedIdentity $UserAssignedIdentity