Skip to content

create resource group with authenticated user in rg name? #7999

Answered by brwilkinson
jhic asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jhic
Comment options

Answer selected by jhic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants