Azure / azure-devtestlab

Azure DevTestLab artifacts, scripts and samples
MIT License
458 stars 602 forks source link

getDeploymentOutput not working #815

Open bobbyangers opened 2 years ago

bobbyangers commented 2 years ago

Despite OutputTemplateVariables = true

export async function getDeploymentOutput(armClient: ResourceManagementClient, resourceGroupName: string): Promise<any[]> { 167 >> const deploymentName = results._response.parsedBody[0].name; } is getting the last "deployment" instead of looking for the last "full" deployment, ie : DeploymentName = Dtl3p5bv1hko

So it's not getting the correct deployment information.

Finished updating Lab Environment ''.

[debug]environmentResourceGroupId=/subscriptions/***/resourcegroups/xx-devtest-lab1-rg

[debug]DeployUtil: Getting deployment output for resource group 'xx-devtest-lab1-rg'.

[debug]DeployUtil: Completed getting deployment output for resource group 'xx-devtest-lab1-rg'.

[debug]task result: Succeeded

In my case, my azuredeploy.json contains "sub" deployments, so the "last" deployment is not the main deployment.

Can we fix this to get the correct deployment based on the DeploymentName, not the one in position 0 ?

leovms commented 2 years ago

@bobbyangers, I looked at the code for getDeploymentOutput and, unless I am misreading it, deploymentOutput is an array. It actually enumerates all the different deployment outputs based on the deploymentName. Later in the code, where it is used, it seems to also process a collection and sets the different variables accordingly.

Can you please elaborate so we can have a better understanding of where things may be failing?

rangers-globecar commented 2 years ago

167 >> const deploymentName = results._response.parsedBody[0].name;

Please look at the line 167, in bold.... it's not looping through anything, it's take the first value.

leovms commented 2 years ago

Ah, I understand what you mean. The expectation is that we traverse through all, not just the first one. Thank you for the clarification. I missed that tidbit.