Open johnsonawane opened 3 years ago
ARM
@johnsonawane I take it you are referring to this 3-exercise-create-and-deploy-template.
That page gives you the option to select your "Azure shell"
I believe it is an error on that page and "Azure CLI" option should be named "Bash" If you select PowerShell in that page and use a PowerShell command prompt on your Windows 10 laptop you can follow along
$templateFile="azuredeploy.json"
$today=date -Format "dd-MMM-yyyy"
$DeploymentName="addstorage-$today"
az group deployment create --name $DeploymentName --template-file $templateFile
You won't be able to use .bat files. PowerShell commands can be stored in .ps1 files, but you may have to use the Set-ExecutionPolicy command to allow these to run.
Thanks Martin,
Appreciate the quick response!
Cheers Sunil
On Wed, 1 Sep 2021 at 8:51 PM, Martin Stenhoff @.***> wrote:
@johnsonawane https://github.com/johnsonawane I take it you are referring to this 3-exercise-create-and-deploy-template https://docs.microsoft.com/en-us/learn/modules/create-azure-resource-manager-template-vs-code/3-exercise-create-and-deploy-template?WT.mc_id=devops-10187-chnoring&ns-enrollment-type=LearningPath&ns-enrollment-id=learn.deploy-manage-resource-manager-templates&pivots=cli .
That page gives you the option to select your "Azure shell"
- PowerShell
- Azure CLI
I believe it is an error on that page and "Azure CLI" option should be named "Bash" If you select PowerShell in that page and use a PowerShell command prompt on your Windows 10 laptop you can follow along
$templateFile="azuredeploy.json" $today=date -Format "dd-MMM-yyyy" $DeploymentName="addstorage-$today" az group deployment create --name $DeploymentName --template-file $templateFile
You won't be able to use a .bat files. PowerShell commands can be stored in .ps1 files, but you may have to use the Set-ExecutionPolicy command to allow these to run.
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/Azure/azure-cli/issues/19410#issuecomment-910389472, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE5YVDPW7HRX36QF6CFZHKTT7ZAF3ANCNFSM5DFSDIWQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
The bash shell I have on my machine is included with GitForWindows.
Thank you @martinstenhoff. Hopefully Microsoft looks into this. This error is a stumbling block for beginners trying to follow the Azure learn.microsoft track with limited knowledge about devops.
Git for windows changed that experience for me. It solved the error below: "'templateFile' is not recognized as an internal or external command, operable program or batch file."
For "[Errno 2] No such file or directory: '$templateFile'", I only had to edit the json file in my folder and reopen with VScode. There was a wrong syntax/symbol in the original file create from VSCode.
Describe the bug
Variables cannot be declared on the cmd prompt (which still appears to be looking for a cmd command only. For instance, the 'set' command works)
To Reproduce
In the Microsoft Learn training module on ARM Templates the following doesn't work on my Windows 10 laptop that has the Azure CLI for Windows version 2.27.2 (core) installed:--->>
Deploy the parameterized ARM template Here, you change the name of the deployment to better reflect what this deployment does and fill in a value for the new parameter.
Run the following Azure CLI commands in the terminal. This snippet is the same code you used previously, but the name of the deployment is changed. Fill in a unique name for the storageName parameter. Remember, this name must be unique across all of Azure. You can use the unique name you created in the last unit. In that case, Azure will update the resource instead of creating a new one.
Azure CLI
Copy templateFile="azuredeploy.json" today=$(date +"%d-%b-%Y") DeploymentName="addnameparameter-"$today
az deployment group create \ --name $DeploymentName \ --template-file $templateFile \ --parameters storageName={your-unique-name}
To execute the above on the cmd prompt I run this .bat file:-->>
templateFile="azuredeploy.json" today=$(date +"%d-%b-%Y") DeploymentName="addnameparameter-"$today
az deployment group create --name $DeploymentName --template-file $templateFile --parameters storageName={sunilstorage786b}
This is response I get:--->> C:\Users\user>Update-Resource-via-ARM-Template.bat
C:\Users\user>templateFile="azuredeploy.json" 'templateFile' is not recognized as an internal or external command, operable program or batch file.
C:\Users\user>today=$(date +"b-Y") 'today' is not recognized as an internal or external command, operable program or batch file.
C:\Users\user>DeploymentName="addnameparameter-"$today 'DeploymentName' is not recognized as an internal or external command, operable program or batch file.
C:\Users\user>az deployment group create --name $DeploymentName --template-file $templateFile --parameters storageName={sunilstorage786b} [Errno 2] No such file or directory: '$templateFile'
Expected behavior
I expected the code given on the Learn page to run because apparently declaring such global variables is supported in Azure CLI on Windows version 2.27.2. The author of the Learn Module believes that somehow the Windows System is modified by the 2.27.2 package for the cmd prompt to recognize that a variable is being declared. From the above artefacts it is clear that this has not been achieved.
Environment summary
Windows Version:-->> Edition Windows 10 Pro Version 20H2 Installed on 27-04-2021 OS build 19042.1165 Experience Windows Feature Experience Pack 120.2212.3530.0 cmd is being run as user 'user' (Administrator)
Additional context
What am I missing Question Mark What is the Azure CLI extension that needs to be installed for the above to work Question Mark