JetBrains/teamcity-azure-agent

Creating cloud profile image for type:Docker Os: Win fails

ivog opened this issue · 3 comments

ivog commented

When trying to add an agent image of type docker to azure cloud profile with the following settings:

deployment: specific resource group
resourcegroup: teamcity
docker image: jetbrains/teamcity-agent
os-type: windows
nameprefix: win-teamcity-agent
instance limit: 1
number of cores: 1
memory (GB): 2

I get a deployment error in azure with the following error message:

The environment variable name in container 'win-teamcity-agent1' of container group 'win-teamcity-agent1' is invalid. A valid environment variable name must start with alphabetic character or '', followed by a string of alphanumeric characters or '' (e.g. 'my_name', or 'MY_NAME', or 'MyName').

I don't get this when i select os-type: linux

Environment

Azure ARM Template

  • TeamCity version: 2017.2.3 (build 51047)
  • Azure plugin version: Azure Resource Manager Cloud Support 0.8.1

@ivog, thanks for reporting, it looks like result of recent Azure portal upgrade.

This issue has recently caught us out, so we did a bit of investigating. From the debug cloud log file \ ARM template we attributed this error to the following environment variables;

TC_AZURE_system.cloud.profile_id
TC_AZURE_teamcity.cloud.instance.hash
TC_AZURE_azure.instance.name

We reached out to Microsoft for clarity on this behavior, their explanation was:

... the environment variable name should follow the regex: [A-Za-z_][A-Za-z0-9_]* ...
We add the validation as we find Linux doesn't support '.' in the environment variable, so the ACI uses the common valid character set from all OS types.

They also offered the following pattern as a potential workaround;

... add a startup script and start the container like:
"command": [ "powershell", "-Command", ".\start.ps1" ]
You can assign the desired environment variables in the script:
${env:Some.Dots} = ${env:Some_Dots}
Thus, you can define Some_Dots in the environment variable.

There's a few hoops to jump through to get this working (agent image customization & safely encoding the . character within teamcity-azure-agent's ARM generation) so I'm unsure if the best approach is to just switch to underscores or pursue this further.

@ivog, @eric-winkler, thanks for reporting, the problem was fixed in the version 0.8.5:
https://plugins.jetbrains.com/plugin/9260-azure-resource-manager-cloud-support