Skip to content

Instantly share code, notes, and snippets.

Created September 26, 2017 01:12
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Create Azure Container Registry via Azure CLI
Create Azure Container Registry. Requires azure-cli >= 2.0.13
.\create-acr.ps1 -RegistryName myacr -ResourceGroup sc-acr -Location westus -Sku Basic
.\create-acr.ps1 -RegistryName myacr -ResourceGroup sc-acr -Location eastus -Sku Managed_Basic
.\create-acr.ps1 -RegistryName myacr -ResourceGroup sc-acr -Location westcentralus -Sku Managed_Basic
.\create-acr.ps1 -RegistryName myacr -ResourceGroup sc-acr -Location westcentralus -Sku Managed_Standard -EnableAdmin
[Parameter(Mandatory=$true)] $RegistryName,
[Parameter(Mandatory=$true)] $ResourceGroup,
[Parameter(Mandatory=$true)] $Location,
[Parameter(Mandatory=$true)] $Sku,
[Parameter(Mandatory=$false)][switch] $EnableAdmin=$false
Write-Error $_.ErrorDetails.Message
Write-Error $_.InvocationInfo.PositionMessage
Write-Error $_.CategoryInfo.ToString()
Write-Error $_.FullyQualifiedErrorId
$e = $_.Exception
while ($e.InnerException) {
$e = $e.InnerException
$msg += "`n" + $e.Message
$groupExists = az group exists -n $ResourceGroup
if ($groupExists -ne "true"){
$response = Read-Host -Prompt "Group $ResourceGroup does not exist. Do you want to create one? [yes(y)/no(n)]"
if ($response -ieq "yes" -or $response -ieq "y"){
$location = Read-Host "Enter location for resource group (e.g. westus, eastus, etc.)"
az group create -n $ResourceGroup --location $location
Write-Host "Must have existing resource group to create ACR. Script terminated." -ForegroundColor Red
az acr create -n $RegistryName -g $ResourceGroup --location $Location --sku $Sku --admin-enabled $($EnableAdmin.ToString().ToLowerInvariant())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment