Hi I have a simple Azure DevOps Pipeline
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: AzurePowerShell@5
inputs:
azureSubscription: 'Azure-DevOps'
ScriptType: 'FilePath'
ScriptPath: 'az-ps-scripts/session-07/vnet/vnet.ps1'
ScriptArguments: '-RGNAME RunFmPp'
azurePowerShellVersion: 'LatestVersion'
workingDirectory: 'az-ps-scripts/session-07/vnet/'
As you can see it has a ScriptArguments: '-RGNAME RunFmPp' and it runs vnet.ps1 script.
But in fact, I do not know how can my vnet.ps1 script acces this argument from Azure DevOps.
This script create a Resource Group for Azure, I would like tho use -RGNAME here:
$rg = @{
Name = $RGNAME
Location = $vnetConf.Location
}
New-AzResourceGroup @rg -Force
But with $RGNAME it does not work, so does anyone know how can this script acces this argument from azure devops pipeline?
>Solution :
Declare your parameter(s) in a param() block at the top of your script:
param(
[string]$RGNAME
)
$rg = @{
Name = $RGNAME
Location = $vnetConf.Location
}
New-AzResourceGroup @rg -Force