Azure / Azure/azure-devtestlab

Task AzureDevTestLabsCreateVM can only allow 1 parameter being overrided

Open
#649 4 comments 1 reaction 0 assignees View on GitHub
bug tasks
Dominant language
PowerShell
Stars
465
Forks
595
PR merge metrics
No merged PRs in 30d

Description

I'm trying to add task **AzureDevTestLabsCreateVM** to my yaml pipeline. The code piece is like below:

- task: AzureDevTestLabsCreateVM@3
displayName: 'Create virtual machine'
inputs:
azureSubscription: $(mySubscription)
LabId: $(myLabId)
VirtualMachineName: $(myVMName)
TemplateFile: 'MyTemplate.json'
ParametersFile: 'MyParameters.json'
ParameterOverrides: |
-password '$(my_password)'
-sasToken '$(my_token)'

Let's say I have 2 parameters (password and sasToken) in the template file, and I'm trying to override them with the yaml variables. I notice that the first parameter (password) doesn't actually get overriden.

After looking at your source code, I think the problem is in function [addParameterOverrides](https://github.com/Azure/azure-devtestlab/blob/2a5c6dd258c7c21a72371eb2f6624b4dce9b4ac5/tasks/Node/src/modules/task-utils/deployutil.ts#L10)() in deployutil.ts. Here is the piece of code in this function:

function addParameterOverrides() {
// Skip some code here
let newParameter: DevTestLabsModels.ArmTemplateParameterProperties = Object.create(DevTestLabsMappers.ArmTemplateParameterProperties);

// Skip some code here
parsedParameterOverrides.forEach(parameterOverride => {
// Code to find a newParameter in the overrides.
});

existingParameters = checkParamArray(newParameter, existingParameters);

return existingParameters;
}

I think there is a bug here. Currently implementation only updates existingParameters with the **last** parameter in parsedParameterOverrides. That's exactly the problem I'm having now. As a solution, the following line of code should be put into the forEach loop:
existingParameters = checkParamArray(newParameter, existingParameters);

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.