Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

–local-gateway2: command not found – AzureCLI

I am trying to create a VPN-connection via AzureCLI but only –local-gateway2 is giving error below:
enter image description here

According to official Microsoft documentation, this should be correct:
https://learn.microsoft.com/en-us/cli/azure/network/vpn-connection?view=azure-cli-latest

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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)'

>Solution :

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)'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading