I have a YAML pipeline which defines a variable called vmPrivateIp:
pr: none
trigger: none
variables:
vmName: 'MyVmName'
vmPrivateIp: '10.0.0.1'
I want to assign this variable with the result of a script task which obtains the private IP of MyVmName:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$IP = (Get-AzNetworkInterface -Name $(vmName)-nic -ResourceGroupName MyResourceGroup).IpConfigurations.PrivateIpAddress
Write-Host "##vso[task.setvariable variable=vmPrivateIp,isOutput=true]$IP"
Write-Host $(vmPrivateIp)
The task runs fine but the variable still contains the initial value
What do I need to do in order to successfully assign the result of the script task to vmPrivateIp?



