Forum Discussion
RJ_Bradach
Feb 02, 2023Copper Contributor
Invalid VM resource name when adding resource to AZDO environment (RHEL 9)
While trying to add a linux VM resource to an Azure Devops pipeline environment, we receive this error. [2023-02-01 23:02:42Z ERR Terminal] Microsoft.VisualStudio.Services.WebApi.VssServiceRespon...
rasad4468
Copper Contributor
When encountering the "Invalid VM resource name" error message when adding a resource in Azure DevOps (AZDO) for a Red Hat Enterprise Linux 9 (RHEL 9) environment, it's possible that the name of the resource you're trying to add contains invalid characters or is too long. In Azure DevOps, VM resource names must meet the following criteria: The name must start with a letter. The name can contain only letters, numbers, and the hyphen (-) character. The name must contain between 3 and 23 characters. If your resource name doesn't meet these criteria, you'll need to change it to a valid name before you can add it to your AZDO environment.
RJ_Bradach
Feb 02, 2023Copper Contributor
Some more information we could provide. This error has occurred on v2.214.1 as well as v3.217.0.
We tried changing the $HOSTNAME within the script call to just using the VM resource name without the .az.example.com". It still uses our FQDN with the invalid periods.
We tried a different VM resource to attach to our pipeline env. Same environment RHEL 9, except we used a shorter VM name matching our hostname, neither containing invalid characters. We ran the v3.217.0 version of the registration script. We received this error
./env.sh: line 44: --environment: invalid variable name
This is the script we used
mkdir azagent;cd azagent;curl -fkSL -o vstsagent.tar.gz https://vstsagentpackage.azureedge.net/agent/3.217.0/vsts-agent-linux-x64-3.217.0.tar.gz;tar -zxvf vstsagent.tar.gz; if [ -x "$(command -v systemctl)" ]; then ./config.sh --environment --environmentname "php-dev" --acceptteeeula --agent $HOSTNAME --url https://dev.azure.com/example/ --work _work --projectname 'example' --auth PAT --token mnlcnce5la5a6lpgrdfz7gsg3bfxbcrlsawy5tm7isi4px42b6ja --runasservice; sudo ./svc.sh install; sudo ./svc.sh start; else ./config.sh --environment --environmentname "php-dev" --acceptteeeula --agent $HOSTNAME --url https://dev.azure.com/example/ --work _work --projectname 'example' --auth PAT --token mnlcnce5la5a6lpgrdfz7gsg3bfxbcrlsawy5tm7isi4px42b6ja; ./run.sh; fi
We tried changing the $HOSTNAME within the script call to just using the VM resource name without the .az.example.com". It still uses our FQDN with the invalid periods.
We tried a different VM resource to attach to our pipeline env. Same environment RHEL 9, except we used a shorter VM name matching our hostname, neither containing invalid characters. We ran the v3.217.0 version of the registration script. We received this error
./env.sh: line 44: --environment: invalid variable name
This is the script we used
mkdir azagent;cd azagent;curl -fkSL -o vstsagent.tar.gz https://vstsagentpackage.azureedge.net/agent/3.217.0/vsts-agent-linux-x64-3.217.0.tar.gz;tar -zxvf vstsagent.tar.gz; if [ -x "$(command -v systemctl)" ]; then ./config.sh --environment --environmentname "php-dev" --acceptteeeula --agent $HOSTNAME --url https://dev.azure.com/example/ --work _work --projectname 'example' --auth PAT --token mnlcnce5la5a6lpgrdfz7gsg3bfxbcrlsawy5tm7isi4px42b6ja --runasservice; sudo ./svc.sh install; sudo ./svc.sh start; else ./config.sh --environment --environmentname "php-dev" --acceptteeeula --agent $HOSTNAME --url https://dev.azure.com/example/ --work _work --projectname 'example' --auth PAT --token mnlcnce5la5a6lpgrdfz7gsg3bfxbcrlsawy5tm7isi4px42b6ja; ./run.sh; fi