create resource group with authenticated user in rg name? #7999
-
Hello, We are working on building quick labs in our Azure subscription, and it would be nice to name the resource group with the name of the authenticated user actually running the deployment. Is this possible? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is no reliable way to do this, unless you can retrieve the information on the cli and then pass it in, via a parameter. An example of doing this is if you deploy with PowerShell, something similar to. $context = get-azcontext
$user = $context.account.id
$userName = $user -split '@' | select -index 0
New-AzResourceGroup -Name ${user}_lab -Location $location Once you have the userName you could use it to create the RG or if you are doing a Subscription deployment, pass it into the deployment to create the RG in Bicep. Something similar could be done with az cli. |
Beta Was this translation helpful? Give feedback.
This is no reliable way to do this, unless you can retrieve the information on the cli and then pass it in, via a parameter.
An example of doing this is if you deploy with PowerShell, something similar to.
Once you have the userName you could use it to create the RG or if you are doing a Subscription deployment, pass it into the deployment to create the RG in Bicep.
Something similar could be done with az cli.