I'm using the below YAML code to deploy Synapse objects (Datasets/DataFlow/Pipelines) using CLI within the PowerShell core
- task: AzureCLI@2
inputs:
azureSubscription: 'ServiceConnection'
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: 'az synapse dataset create --workspace-name SynapseWorkspaceName --name SQLServer1 --file @"$(System.DefaultWorkingDirectory)/dataset/SqlServer.json"'
I'm getting the below error
No characters are allowed after a here-string header but before the end of the line.
Note: I'm able to create Synapse objects using the same Azure CLI command (shown above) in the below scenarios
Azure CLI command also allows us to pass the JSON content (the issue is when you pass just the JSON file name) which is working fine.
Appreciate the help.
Thanks,
Praveen
I can reproduce the same error when running the command within pwsh
installed on a Linux machine and PowerShell on a Windows machine.
According to Tips for using the Azure CLI | Microsoft Learn
There are special characters of PowerShell, such as at
@
. To run Azure CLI in PowerShell, add`
before the special character to escape it.
Thus, the AzureCLI
pipeline task is working with the help of backtick character `
.
pool:
vmImage: ubuntu-latest
steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'ARMSvcCnnAutoSub7'
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
az synapse dataset create --workspace-name mysynapseworkspace --name SQLServer1 --file `@"$(System.DefaultWorkingDirectory)/dataset/SqlServer.json"
Hope this helps.