我在 Azure 中创建容器应用程序时遇到错误。当我尝试使用 Terraform 创建应用程序时,出现以下错误:
无效值:“testecontainerregistry.azurecr.io/diouxx/glpi:latest”:GET https:?scope=repository%3Adiouxx%2Fglpi%3Apull&service=testcontainerregistry.azurecr.io:UNAUTHORIZED:需要身份验证'。
我已验证我的 Azure 容器注册表 (ACR) 凭据是否正确。我正在使用 Terraform 创建容器应用程序,并在 Terraform 配置文件中指定了图像“testecontainerregistry.azurecr.io/diouxx/glpi:latest”。
有人在使用 Terraform 在 Azure 中创建容器应用程序时遇到过这个问题吗?我需要配置或检查某些特定内容才能解决此身份验证错误吗?
它最终可以使用 ghcr.io 来处理这些参数:
resource "azapi_resource" "YOUR-CONTAINER-NAME" {
type = "Microsoft.App/containerApps@2022-03-01"
name = "YOUR-CONTAINER-NAME"
parent_id = azurerm_resource_group.aca.id
location = azurerm_resource_group.aca.location
body = jsonencode({
properties = {
managedEnvironmentId = azapi_resource.env.id
configuration = {
ingress = null
registries = [{
server = "ghcr.io"
username = "YOUR-USER-NAME"
passwordSecretRef = "ghcr-password"
}]
secrets = [{
name = "ghcr-password"
value = "YOUR-GITHUB-ACCESS-TOKEN"
}]
}
template = {
containers = [
{
name = "YOUR-CONTAINER-NAME"
image = "ghcr.io/YOUR-USER-NAME/YOUR-CONTAINER-NAME:latest"
resources = {
cpu = 0.25
memory = "0.5Gi"
}
}
]
scale = {
minReplicas = 1
maxReplicas = 1
}
}
}
})
}