Azure / Azure/azure-cli

Azure CLI running on Windows 10; version core= 2.27.2 :----->>> Variables

Open
#19,410 6 comments 0 reactions 1 assignee Assigned to @yanzhudd View on GitHub
act-identity-squad ARM customer-reported feature-request
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.