Skip to content

Instantly share code, notes, and snippets.

@peteraritchie
Created November 15, 2022 14:13
Show Gist options
  • Save peteraritchie/d221fdc8f69d970952055505465f9754 to your computer and use it in GitHub Desktop.
Save peteraritchie/d221fdc8f69d970952055505465f9754 to your computer and use it in GitHub Desktop.
$webappname = "mywebapp752638527"
$resourceGroupName = 'learn-deploy-container-acr-rg'
$location = 'eastus'
$appServicePlanName="$webappname-deploy"
$tags = @{'createdDate'=(Get-Date).ToString("yyyy-MM-dd"); 'intention'='learn'}
$containerRegistryName="peterritchie"
$webImageName="webimage"
az configure --defaults group=$resourceGroupName location=$location
# Create a resource group, if not already
#if (!(Get-AzResourceGroup $resourceGroupName -ErrorAction SilentlyContinue)) { New-AzResourceGroup -Name $resourceGroupName -Location $location }
if($(az group exists) -eq $false) {az group create -n $resourceGroupName}
Write-Host -ForegroundColor Green "acr create"
az acr create --name $containerRegistryName --sku Standard --admin-enabled true
az configure --defaults acr=$containerRegistryName
cd ./mslearn-deploy-run-container-app-service/dotnet
Write-Host -ForegroundColor Green "acr build"
#az acr build --registry $containerRegistryName --image $webImageName .
az acr build --image $webImageName .
cd ../..
Write-Host -ForegroundColor Green "appservice plan create"
az appservice plan create --name $appServicePlanName --is-linux --sku FREE --tags $tags
Write-Host -ForegroundColor Green "webapp create"
az webapp create --name $webappname --plan $appServicePlanName --deployment-container-image-name "peterritchie.azurecr.io/$($webImageName):latest"
az configure --defaults web=$webappname
Write-Host -ForegroundColor Green "webapp deployment container config"
az webapp deployment container config --enable-cd true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment