Currently, I have a param in my bicep script to set the location:
targetScope = 'subscription'
@minLength(1)
param location string
@minLength(1)
param resourceGroupName string
resource myRG 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: resourceGroupName
location: location
}
However, since I need to pass in the location to the command line argument, that’s repetition:
# az deployment sub create --location eastus --template-file main.bicep
Please provide string value for 'location' (? for help):
I couldn’t find a way to just get the value of my --location argument into the bicep script. I know I could set it as an environment variable and change the invocation to something like az deployment sub create --location $LOCATION --template-file main.bicep --parameters location=$LOCATION, but I wonder if there is a proper way to not have to repeat the location in two different places?
>Solution :
Unfortunately, it’s not possible.
The --location parameter for subscription scope deployments tells ARM where to store deployment metadata.
There is no real relationship between the az argument, and your Bicep parameter. And there is no concept of a location associated with a subscription.
Not often I say it, but no. No way around it in this instance.