Creating an app service using a container image

Let's walk through how to create an app service using the previously published image, which is already present in Azure Container Registry, that is, <registry_name>.azurecr.io/catalog_api:v1. As a first step, we need to create an app service plan using the following command:

az appservice plan create --name catalogServicePlan --resource-group <service_group_name> --sku FREE --is-linux

The app service plan is required for the creation of the app service: it defines a set of computing resources that are used to run all of the app services that are part of the same plan. For this example, we will use the most basic service plan, which can be specified using the following flag: --sku FREE. This plan supports up to 10 instances and it does not provide any additional autoscale capability. 

Now that we've created all of the requirements, we can proceed by executing the appservice-deploy.sh file, which is located in the root of the project:

#!/bin/bash
# Set the service group name
export resource_group=handsOnAppService
# Set the plan
export plan=catalogServicePlan
# Set the service name
export app_service_name=catalog-srv
# Set the api ASPNETCORE_ENVIRONMENT variables
export environment=StageAppServices
# Defines the ACR registry URL
export registry_address=<registry_address>.azurecr.io

# Create the app service
az webapp create --resource-group ${resource_group}
--plan ${plan}
--name ${app_service_name}
--deployment-container-image-name ${registry_address}/catalog_api:v1

# Set the ASPNETCORE_ENVIRONMENT variable
az webapp config appsettings set -g ${resource_group}
-n ${app_service_name}
--settings ASPNETCORE_ENVIRONMENT=${environment}

The preceding script creates the web app using the az webapp create instruction, and after the creation of the app service, it proceeds by executing the az webapp config appsettings set command to set the right ASP.NET Core environment value. Once the script has been executed, we can continue by checking the status of the app service in the portal:

Furthermore, we can verify the status of the service by calling the health check URL: http://catalog-api.westeurope.azurecontainer.io/health.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.127.141