Issue with Private Image Repository Configuration when Creating Container App Job via Terraform with AzAPI

PU_A_EDSASSE (EXT) 0 Reputation points
2023-12-01T12:26:53.5833333+00:00

I'm encountering an issue when using Terraform along with AzAPI to create Container App Jobs in Azure. There seems to be a bug in the interpretation of the sent JSON, resulting in two main problems.

Problem 1: Incorrect Configuration when Using a Private Image Repository:

When creating a Container App Job that uses a private image repository, the configuration in the portal does not reflect this definition.

afterDeployment

The sent JSON appears to be correct, but upon checking the execution logs, it's evident that the private repository is not being used.

downloadRepoFailed

Problem 2: Issues with Repository and Tag Presentation when Modifying Settings in the Portal:

Manually changing the configuration in the portal by setting the "Image Type" to "Private" reveals that the "Registry login server" is correctly displayed. However, there's a second issue: in the "Image and tag" section, the repository "myrepo" is not presented correctly, even though it should be "myrepo/myjob:3.0.0.2".

switchToPrivate

After making these manual adjustments in the portal, the Container App Job is able to download the image and execute successfully. It's important to note that, even after the changes, the JSON extracted from the portal, both initially and after adjustments, remains exactly the same. This raises the hypothesis that the issue might lie in the JSON interpretation at the time of Job creation.

{
    "id": "/subscriptions/.../providers/Microsoft.App/jobs/my-job",
    "name": "my-job",
    "type": "Microsoft.App/jobs",
    "location": "West Europe",
    "tags": {
        "environment": "d"
    },
    "systemData": {
        ...
    },
    "properties": {
        "provisioningState": "Succeeded",
        "environmentId": "/subscriptions/.../providers/Microsoft.App/managedEnvironments/my-jobs",
        "workloadProfileName": null,
        "configuration": {
            "secrets": [
                {
                    "name": "reg-pswd-docker-image"
                }
            ],
            "triggerType": "Schedule",
            "replicaTimeout": 30,
            "replicaRetryLimit": 1,
            "manualTriggerConfig": null,
            "scheduleTriggerConfig": {
                "replicaCompletionCount": 1,
                "cronExpression": "*/5 * * * *",
                "parallelism": 1
            },
            "eventTriggerConfig": null,
            "registries": [
                {
                    "server": "art.myserver.com",
                    "username": "TECHUSER",
                    "passwordSecretRef": "reg-pswd-docker-image",
                    "identity": ""
                }
            ],
            "dapr": null
        },
        "template": {
            "containers": [
                {
                    "image": "myrepo/myjob:3.0.0.2",
                    "name": "myjob-cronjob",
                    "env": [
                        {
                            "name": "alert_minutes_tolerance_duration",
                            "value": "10"
                        }
						...
                    ],
                    "resources": {
                        "cpu": 0.5,
                        "memory": "1Gi",
                        "ephemeralStorage": "2Gi"
                    },
                    "volumeMounts": [
                        {
                            ...
                        }
                    ]
                }
            ],
            "initContainers": null,
            "volumes": [
                {
                   ...
                }
            ]
        },
        "eventStreamEndpoint": ...
    },
    "identity": {
        ...
    }
}

In terraform with azapi I'm using the version below for the jobs:

resource "azapi_resource" "this" {
  type      = "Microsoft.App/jobs@2023-05-01"
...

I appreciate any guidance or corrections related to this issue.

Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.