Forum Discussion

RJ_Bradach's avatar
RJ_Bradach
Copper Contributor
Feb 02, 2023

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.VssServiceResponseException: Invalid Virtual Machine resource name 'example.az.example.com'. A valid name
is less than 128 characters in length and does not contain the following characters: ',', '"', '/', '\', '[', ']', ':', '|', '<', '>', '+', '=', ';', '?', '*', '.'.
---> System.ArgumentException: Invalid Virtual Machine resource name 'example.az.example.com'. A valid name is less than 128 characters in length and does not contain the following
characters: ',', '"', '/', '\', '[', ']', ':', '|', '<', '>', '+', '=', ';', '?', '*', '.'.
--- End of inner exception stack trace --
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.HandleResponseAsync(HttpResponseMessage response, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync(HttpRequestMessage message, HttpCompletionOption completionOption, Object userState, CancellationToken cancellationTo
ken)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync[T](HttpRequestMessage message, Object userState, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync[T](HttpMethod method, IEnumerable`1 additionalHeaders, Guid locationId, Object routeValues, ApiResourceVersion versio
n, HttpContent content, IEnumerable`1 queryParameters, Object userState, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Services.Agent.Listener.Configuration.EnvironmentVMResourceConfigProvider.AddAgentAsync(AgentSettings agentSettings, TaskAgent agent, CommandSettings command) in
/home/vsts/work/1/s/src/Agent.Listener/Configuration/ConfigurationProvider.cs:line 482
at Microsoft.VisualStudio.Services.Agent.Listener.Configuration.ConfigurationManager.ConfigureAsync(CommandSettings command) in /home/vsts/work/1/s/src/Agent.Listener/Configuration/Config
urationManager.cs:line 250

  • rasad4468's avatar
    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's avatar
      RJ_Bradach
      Copper Contributor

      rasad4468 Is it possible to circumvent changing the VM name? Our VM name is valid, as our VM is pre-existing. Our hostname is invalid. 

    • RJ_Bradach's avatar
      RJ_Bradach
      Copper 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

Resources