You can use Azure Command Line Interface with PowerShell to create infrastructure as code (IaC) scripts, for implementing deployment of resources in Azure platform services. When you try to create a web app in Azure with run time specified with Azure CLI in PowerShell, | symbol used in runtime specification causes issues as it is trying to do a pipe operation in PowerShell. Let’s look at the issue and how to get it resolved in PowerShell and Azure CLI based IaC scripts.
When the script below executed, $nodeRuntime is set as node|6.12 the script fail with issue shown in below image.
$webAppPricePlan = az appservice plan show -n $azureFunctionsAppPlanName -g $sharedResourceGroupName | ConvertFrom-Json
Write-Host ("Web App " + $name + " is not found. Creating it...")
az webapp create -n $name -g $resourceGroupName -p ($webAppPricePlan.id) -r $nodeRuntime
'6.12' is not recognized as an internal or external command, operable program or batch file.
How to Resolve
To resolve this issue, we can use --% as escape to | symbol. However, to run this in a PowerShell script with variables, we have to copy it as an evaluated expression. The execute it via Invoke-Expression. If the script is getting executed with hardcoded values instead of variable usage you do not have to use Invoke-Expression.
$exp = 'az webapp create -n ' + $name + ' -g ' + $resourceGroupName + ' -p ' + ($webAppPricePlan.id) + ' --% -r ' + '"' + $nodeRuntime + '"'
Once this is resolved the script can be used in Azure Pipelines to create node web app resources in Azure.
SQL Server Integration Services (SSIS) projects can be created to perform ETL (Extract Transform and Load) operations. As Implementing of Co...
Task groups are really useful to share common actions with multiple build or release pipelines in Azure DevOps (VSTS). You can group multip...
You can easily clone a build and create a new build definition in the same team project. This is useful when you have similar type of applic...
Generally windows services are deployed by creating an msi installer. It is possible to deploy msi via VSTS/TFS release management using the...
Adding Azure Subscription to Azure DevOps as service connection is really simple when you have the same account you are using for Azure Dev...