I have Variables.ps1 where all the variables initialized:
$RG="bicepRG"
$Subscription="subscription_id"
$location="eastus"
Azure CLI commands are in the different file of the same path:
az login --only-show-errors -o table --query Dummy
az account set -s $Subscription
az login
command works fine (prompt for login > success result).
az account set -s $Subscription
command giving me the error argument --subscription/-s/--name/-n: expected one argument
I'm at the same folder path (C:\Users\hasher\source\repos\bicep>
) while running above Azure CLI Commands on Visual Studio Code.
I didn't find this error related solutions in the Search.
I tried to solve myself, its solved. Posting the resolution which would help the community if anyone face similar issue in the future:
argument --subscription/-s/--name/-n: expected one argument
I have been logged in to Azure Subscription using Azure CLI and it's been a long time so az account set
command is unable to get the Subscription Id from the Variables.ps1
file.
And Then I have initialized the Variables.ps1
in the Visual studio Code terminal and then ran the commands az login, az account set
(as given in the Question) --> Logged-in and Set the Subscription context successfully.