Reputation: 141
I am trying to deploy a vm using ARM template and use the IP of the machine as powershell target machine Ip to run scripts inside the VM that got deployed.
I added output variable in arm template which is giving the Ip address of the machine that is getting deployed.
"outputs": {
"adminUsername": {
"type": "string",
"value": "[parameters('adminUsername')]"
},
"PublicIPAddress": {
"type": "string",
"value": "[reference(parameters('publicIpAddressName')).ipAddress]"
}
}
I am capturing that Ip as Deployment Output like this
And in the powershell task i am able to print that Ip address like this
But when i use the same as target machine IP like this it is saying that hostname cannot be parsed
I am attaching the outputs that i am getting here
Can Someone help me with this? Thanks in advance.
Upvotes: 0
Views: 229
Reputation: 30313
It seems the Deployment Output value cannot be referenced in the task PowerShell on target machines
.
Please try setting the Deployment Output to an environment variable in scripts via powershell task. See below:
Add a powershell task to run below scripts to set the Deployment Output to variable IpAddress
: See here.
$var=ConvertFrom-Json '$(ArmOutput)'
$value=$var.PublicIPAddress.value
Write-Host "##vso[task.setvariable variable=IpAddress;]$value"
In the task PowerShell on target machines
, you can reference the variable IpAddress
created in above powershell task:
Upvotes: 1