How to use ARM template in CommandToExecute section which uses chcocolatey script

Abhishek Rao 1 Reputation point
2020-11-03T07:24:50.74+00:00

Hi,
I am using chocolatey command to install deployment agent after creating my VM in azure portal.
I have below command in the extension script.

"commandToExecute": "[concat('C:\ProgramData\chocolatey\choco.exe install azure-pipelines-agent --params \"''/Directory:c:\agent /Token:', parameters('myPAT'),' /DeploymentGroup:true /projectname:', parameters('ProjectName'),' /deploymentgroupname: ', parameters('DeploymentGroupName'), ' /DeploymentGroupTags:%COMPUTERNAME% /LogonAccount:', [concat(parameters('newVMName'), '\', parameters('UserName'))],' /LogonPassword:', parameters('password'),' /Replace /Url:https://dev.azure.com/xyz ''\" -y ')]"

I needed to use ARM template parameters in above command , not sure what I have written is correct. Can anybody suggest how should I use ?

Note : ProjectName is having Space in it

Thanks in advance,
Abhishek

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,907 questions
{count} votes

2 answers

Sort by: Most helpful
  1. prmanhas-MSFT 17,901 Reputation points Microsoft Employee
    2020-11-03T14:05:18.59+00:00

    @Abhishek Rao Firstly, apologies for the delay in responding on this and any inconvenience this issue may have caused.

    Chocolatey is a package manager for windows (similar to Yum/Apt-Get) used by Azure customers for installing packages. Chocolatey allows you to use the command line to install packages from a central repository onto a Windows operating system. You can create and manage your own repository, and Chocolatey can install packages from any number of repositories that you designate.

    Below will be architecture for same:

    37213-image.png

    Did you got a chance to go through below documentation which talks about integration of Chocolatey in Azure and might be helpful with your scenario:

    https://learn.microsoft.com/en-us/azure/automation/automation-dsc-cd-chocolatey

    Hope it helps.

    Do let me know if you have any further queries.

    Please 'Accept as answer' if it helped, so that it can help others in the community looking for help on similar topics


  2. prmanhas-MSFT 17,901 Reputation points Microsoft Employee
    2020-11-19T07:59:49.267+00:00

    @Abhishek Rao Apologies for the delay in response. I got few inputs from our team as below:

    [concat(
    'C:\ProgramData\chocolatey\choco.exe install azure-pipelines-agent --params \"''/Directory:c:\agent /Token:', <--- I think this is meant to be two segments? Not sure why \” is there at all, but after the first ‘ should probably be a comma before the directory portion
    parameters('myPAT'),
    ' /DeploymentGroup:true /projectname:',
    parameters('ProjectName'),
    ' /deploymentgroupname: ',
    parameters('DeploymentGroupName'),
    ' /DeploymentGroupTags:%COMPUTERNAME% /LogonAccount:',
    [concat(parameters('newVMName'), <--- Why does this start a new concat function? I think this is part of the break, too. Should probably just be the parameter portion as a argument to the first concat
    '\',
    parameters('UserName'))], <--- This looks like it’s trying to end that second concat. Removing the 2nd concat will clean this up and since it’s one giant concat, no reason to sub-concat that I’m aware of
    ' /LogonPassword:',
    parameters('password'),
    ' /Replace /Url:https://dev.azure.com/xyz ''\" -y ' **<--- This is another with extra ticks **
    )]

    In addition I would suggest as this issues need more investigation and live troubleshooting for quicker resolution I would recommend you to contact azure support. If you have a support plan, requesting you to file a support ticket, else please do let us know, we will try and help you get a one-time free technical support.

    Thank you for your cooperation on this matter and look forward to your reply.

    Please 'Accept as answer' if it helped, so that it can help others in the community looking for help on similar topics

    0 comments No comments

Your answer

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