I am trying to create a VPN-connection via AzureCLI but only --local-gateway2 is giving error below:
According to official Microsoft documentation, this should be correct: https://learn.microsoft.com/en-us/cli/azure/network/vpn-connection?view=azure-cli-latest
stages:
- stage: Deploy_VPN_Connection
jobs:
- job: Create_IPSec_VPN_Connection
continueOnError: false
steps:
- task: AzureCLI@2
displayName: 'Create_IPSec_VPN_Connection'
inputs:
azureSubscription: '$(ServiceConnectionName)' # Use Service Connection to deploy the code to Azure.
ScriptType: 'bash'
scriptLocation: 'inlineScript'
InlineScript: | # Powershell Inline commands
# Select Subscription to use
az account set --subscription '$(SubscriptionName)'
# Retrieve the shared key from Key Vault
# SHARED_KEY=$(az keyvault secret show --vault-name '($KeyVaultName)' --name '($SecretName)' --query value -o tsv)
# Deploy IPsec VPN Site-to-Site in Azure
az network vpn-connection create \
--name '($VPNConnectionName)' \
--resource-group '($ResourceGroupName)' \
--location '($Location)' \
--vnet-gateway1 '($VNetGatewayName)' \
--shared-key 'TEST123!' \
--local-gateway2 '($LocalNetworkGatewayName)'
If your pipeline was designed to reference the variables defined in your pipeline variables section or library of variable group(s) to run Azure CLI commands, it should probably use $(var)
instead of ($var)
. Please try running the script below to make sure the variables defined in or linked to your pipeline is expanded as expected.
az network vpn-connection create \
--name '$(VPNConnectionName)' \
--resource-group '$(ResourceGroupName)' \
--location '$(Location)' \
--vnet-gateway1 '$(VNetGatewayName)' \
--shared-key 'TEST123!' \
--local-gateway2 '$(LocalNetworkGatewayName)'