1

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 access this argument provided by this pipeline. This script creates a Resource Group for Azure, I would like tho use -RGNAME here:

$rg = @{
    Name = $RGNAME
}
New-AzResourceGroup @rg 

But with $RGNAME it does not work, so does anyone know how can this script acces this argument from azure devops pipeline?

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.