Page 29 - MSDN Magazine, April 2018
P. 29
Azure AD B2C Tenant Account | Social Credentials
Work Account – Azure AD | Azure AD B2B
Azure
Customer Portal – ASP.NET Core 2.0 MVC
Azure Key Vault
SQL
Azure SQL Database
Azure AD B2C Tenant
Azure AD Tenant
consumer (external) portal appli- cations in the solution were packaged for Docker Linux con- tainers. Before you can use the tool in Visual Studio 2017, you must install Docker for Windows and perform the configuration steps described at bit.ly/2F6YBRb. I created the Docker container images using the “Release” configuration in Visual Studio 2017 for each of the Web application projects.
Running the Docker commands in the console windows displays two container images, one for each por- tal application, as shown in Figure 2.
Customers
Users of Central Agency, Insurance Companies
Internet
Azure Application Gateway
Admin Portal – ASP.NET Core 2.0 MVC
Azure Container Service
Figure 1 Solution Architecture
is used to authenticate the users of the admin portal while Azure Active Directory B2C (Azure AD B2C) is used for the consumers accessing the customer portal. Azure SQL Database stores the metadata information pertaining to the insurance policies created in the solution, and Azure Key Vault holds the sensitive informa- tion that will be used to ascertain the validity and authenticity of each insurance policy. There are some other options, apart from AKS, for deploying containerized applications, like Azure Con- tainer Instances (ACI) and Azure Web Apps for Containers, which are also covered in this article, though not depicted in Figure 1.
ACI provides the quickest way to run a container-based application in Azure.
Modifying the Solution to Suit the New Architecture
Of course, changes to the architecture mean the solution must change. Let’s take a look at how I modified the solution.
Enabling the Web Applications for Docker Containers Visual Studio Tools for Docker provides a turnkey implementation to enable anASP.NET2.0CoreApplicationforbothWindowsandLinuxCon- tainers. Installing this tool gives you a context-driven menu option in your Visual Studio 2017 project that generates all the artifacts required to create a Docker container for the application. The admin and
Uploading Container Images to a Private Registry The container images created earlier were first uploaded to an Azure Container Reg- istry (ACR), from where they would be consumed in Azure Container Services. The ACR instance created for this deployment is “contoso- insacr.” After signing into the registry using the Azure CLI, I executed
Docker commands to upload the container images to this registry:
az acr login --name contosoinsacr --username <username> --password <password> docker tag contosoinsauthorityadminportal contosoinsacr.azurecr.io/ contosoinsauthorityadminportal:web1v1
docker push contosoinsacr.azurecr.io/contosoinsauthorityadminportal:web1v1 docker tag contosoinsextportal:latest contosoinsacr.azurecr.io/ contosoinsextportal:web2v1
docker push contosoinsacr.azurecr.io/contosoinsextportal:web2v1 az acr repository list --name contosoinsacr --output table
The final Docker command lists the container images from the ACR after they were uploaded. Refer to the documentation at bit.ly/2BZ1rdv, which details how to create an ACR and push a Docker image to it.
Deploying Containerized Web Applications
With the admin and external (customer) portal applications pack- aged as containers, there are multiple options available in Azure to deploy them. Let’s take a look.
Deploying to Azure Container Instances ACI provides the quickest way to run a container-based application in Azure, with- out your having to provision any virtual machines to host them or deal with container orchestration to handle more complex scenarios. You simply use the Azure Portal experience to create a new ACI and provide the access credentials and reference to the container images uploaded to the ACR in the steps covered earlier. On completion, the container instance gets provisioned and
assigned a public IP address for accessing the Web application. These steps would be performed for both the admin and customer portal applications. Refer to the documentation available bit.ly/ 2CmuNhK to use the Azure Portal to create an ACI and deploy an appli- cation to it for more information.
Before these applications can be used, you need to configure the “redirect url” in the application
April 2018 23
Figure 2 Docker Images of the Web Applications msdnmagazine.com