Share via

Azure Container Instance - Failed to Create

Brian Bento 0 Reputation points
2026-03-31T17:24:02.7633333+00:00

I am using a PS script to create ACI instances and I have used this script before with no issue at a previous company. However, now when I run it with the updated info I get the following error:

The DNS name label 'alludio-platform-tenants-api-prod' in container group 'alludio-platform-tenants-api-prod' is invalid. It can contain only lowercase letters, numbers and hyphens. The first character must be a letter. The last character must be a letter or number. The value must be between 5 and 63 characters long.

It is quite obvious nothing in the label violates any of the explanations outlined and I even was able to create the container through the web console with the exact same info I provide to the script and it created just fine.

I have updated my Az PS version as well to the latest thinking maybe there was a mismatch on the api on the backend. I don't understand how it can give me this error when its clearly not an issue.

Azure Container Instances

2 answers

Sort by: Most helpful
  1. Brian Bento 0 Reputation points
    2026-03-31T23:46:17.89+00:00

    It turns out the issue was that i was concatenating two strings in line $service-$environment and for some reason it works everything else but not for this dns label - instead I had to do "${service}-${environment}" which makes no sense but it works. I even had tried hardcoding it but that didn't work either so not sure what is going on there.

    Was this answer helpful?

    0 comments No comments

  2. AI answer

    2026-03-31T17:24:27.6566667+00:00

    The error is raised because Azure is validating the DNS name label, not the container group name, and the DNS label must follow stricter rules than the container group name. In PowerShell, the -IPAddressDnsNameLabel parameter on New-AzContainerGroup / New-AzContainerInstanceContainerGroupProfile is what sets this value.

    Key points from the DNS name label rules for Azure Container Instances:

    • Allowed characters: lowercase letters, numbers, and hyphens (-).
    • First character: must be a letter.
    • Last character: must be a letter or number (cannot be a hyphen).
    • Length: 5–63 characters.

    The error message shows that the DNS name label is alludio-platform-tenants-api-prod. Even though this string appears valid, the issue is typically one of the following in the script:

    1. A different value is actually being passed to -IPAddressDnsNameLabel than expected (for example, including a trailing hyphen, whitespace, or an empty/short value after variable expansion).
    2. The DNS label is being set from a variable that contains uppercase characters or invalid characters once concatenated.
    3. The container group name and DNS name label are being confused; the portal may auto-generate a valid DNS label even if the group name is longer or slightly different, while the script explicitly sets an invalid DNS label.

    To resolve:

    1. Explicitly set a valid DNS label in the script:
      • Ensure the value is all lowercase, 5–63 characters, starts with a letter, and does not end with -.
      • Example: -IPAddressDnsNameLabel "alludio-platform-tenants-api-prod".
    2. Log or output the exact value passed to -IPAddressDnsNameLabel before calling New-AzContainerGroup to verify there are no trailing spaces or unexpected characters.
    3. Confirm that the container group name itself also follows its own naming rules (lowercase letters, numbers, hyphens; cannot start or end with a hyphen; no consecutive hyphens; length 1–63) because some tooling can conflate the two when building the request.

    If the same values work in the portal, compare the portal-generated DNS label with what the script sends and align the script’s -IPAddressDnsNameLabel to that format.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

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.