Deploy a Docker multi-container application on Azure Web Apps

Published Jan 15 2019 03:15 PM 4,433 Views
Microsoft
First published on MSDN on Oct 24, 2018
In the last post of my series about Docker we have seen how, thanks to Docker Compose, it's easy to deploy an application composed by multiple components running in different containers.
Thanks to Docker Compose we can run or stop all the containers which compose our application at the same time with a single command; additionally, the tool takes care of creating a dedicated network bridge, so that we can easily put them in communication simply by using the assigned IP address or DNS name.
The biggest advantage of this approach (and, generally speaking, of Docker containers) is that we can take this architecture and deploy it on any machine which hosts the Docker service and be sure that it will always run as expected.

However, until the last post, we have always deployed our solutions based on containers on our local machine. It was great for testing and debugging purposes, but it isn't a realistic scenario. A real application would run on a real server, so that it can be accessed by any user.

And which better place to host our applications than the cloud? Azure is a perfect match for container-based solutions, since it can quickly scale based on the workload.
As we have seen so far, Docker is just a service that can run on any Windows or Linux machine. A simple approach to host our application would be to create a Linux VM on Azure, install Docker and invoke our Docker Compose command on it. However, this solution has some downsides. Since we have created the VM, we are responsible for it. We need to keep it patched, up-to-date with the latest security features, etc.

It would be much better if we could use a PaaS (Platform-As-A-Service) solution? Welcome Azure Web Apps!

Using Azure Web Apps with Docker


Azure Web Apps is an Azure service, which is part of the Azure App Servic e realm, that can host any kind of web application. It's a PaaS service, meaning that we can focus on the web application hosting, without bothering about the underneath hardware and configuration. We can choose the configuration of the machine (based on the workload), we can configure the application platform (for example, by choosing which version of .NET, PHP or Java we want to leverage), but we aren't responsible for maintaining the underline platform. We don't have to take care of keeping the OS or the frameworks up-to-date.

Since a while Azure App Service has added support for Linux machines, meaning that we can host web apps on a machine running Linux instead of Windows. With this feature we get also full Docker support, for a single container or for multiple containers.
This means that, using the same Docker images and compose file we have built to deploy our solution locally, we can deploy our application also on Azure and immediately get all the benefits offered by this powerful platform.

Let's start!

First go to the Azure portal and login with your account. Choose Create a resource and, from the list, choose Web App .



You will be asked to setup your web application:



  • App name is a unique identifier for the app. It will be also the prefix of the default domain to reach this app from Internet. For example, if you call it MyFirstDockerApp , you will be able to access to it using https://myfirstdockerapp.azurewebsites.net

  • The Azure subscription, in case you have one or more.

  • The resource group, which is a way to bundle together all the services required by the web app to work. I suggest to create a new dedicated one, so that at a later stage you can easily delete or move all the resources.

  • The operating system. Choose Linux .

  • The App Service plan / location. Use this option to choose the App Service plan you want to use. An App Service plan is a combination of location (in which Azure region you want to deploy the app) and the pricing tier (which reflects the hardware features of the hosting machine). At the top you will notice that the pricing tiers are split into three different categories: Dev / Test, Production and Isolated. Since we are in testing phase, feel free to choose one of the plans under the first option, which are free or really cheap.


We have left one option behind, because it's the critical one we need for our workload. Under Publish , you can choose Code or Docker Image . Once you choose the second option, you will see at the bottom a new field called Configure container . By clicking on it you will expand, at the right, a new panel where to specify the configuration of your containers:



You have three options:

  • Single container can be used to deploy a single application running in a single container

  • Docker Compose can be used to deploy a solution based on multiple containers using the Docker Compose file format.

  • Kubernetes achieves the same goal of the previous option, but using the Kubernetes file format to describe the containers. In case you never heard of it, Kubernetes is a very popular technology to orchestrate containers created by Google.


Regardless of the choice, you will be able to use different image sources:

  • Quickstart allows to quickly deploy sample solutions to test the Azure App Service platform.

  • Azure Container Registry is a platform provided by Azure to host your own images. Think of it like your own personal Docker Hub repository.

  • Docker Hub is the official Docker repository we have learned to use in the previous posts. From here you can pull all the public images released by developers and companies from all around the globe.

  • Private Registry is the option to choose in case you're hosting your images on your own private repository.


Our scenario is a multi-container solution based on images coming from Docker Hub. If you remember one of the previous posts , we have pushed the images we have built for our web application and our web API to Docker Hub.

Let's choose Docker Compose and then Docker Hub as Image source . We have published our images as public, so leave Public as Repository Access . In the Configuration File field press Browse and look for the docker-compose.yml file we have built in a previous post .

You will see, in the Configuration area, the content of the YML file.



Press Apply and you will be redirected to the Web App configuration page. This time the Configure container field should be reported as Complete . Press Create at the bottom of the section to start the creation of the web app.

The web application will be now deployed and, under the hood, Azure will pull the images we have specified in the Docker Compose file (qmatteoq\testwebapp, qmatteoq\testwebapi and redis) and will spin a container for each of them. Azure is smart enough to understand that the service called web is the only one for which we're exposing the 80 port. As such, this container will be the one exposed directly through the 80 port of the URL that has been assigned to the our App Service.

Everything is awesome... more or less


Let's give a try to our deployment. Open the browser and point it to the URL which was assigned your app service. You should see... this:



Well, this isn't a pleasant surprise. Something bad is happening. Specifically, based on the stack trace, it seems that our web application is failing to communicate with the Web API. The GetStringAsync() method of the HttpClient , which we're using to retrieve the list of blog posts from the Web API, is failing.

Is it possible to get more details? Sure, but first we need to enable some logging. Move to the Diagnostic logs section of your web app and turn it on by choosing File System .



Now try to reload again the website, in order to reproduce the error. Now we should have some logging in the file system of the web application. The easiest way to access them is to choose Advanced Tools from the Development tools section of the web app.



Press the Go button to open Kudu, which is a diagnostic web interface for your application. Typically, Kudu is available at the same URL of the main application, but with the prefix scm between the app name and the domain. For example, if your application is hosted at https://mydockerwebapp.azurewebsites.net , the Kudu interface will be available at https://mydockerwebapp.scm.azurewebsites.net .

As you can see in the web interface, one of the available REST API is called Current Docker logs :



Click on the Download as zip button to download a compressed file, which will contain multiple log files: a generic one for the Docker service and a specific one for each container that has been created.



Let's start by opening the one related to the web application, which ends with the suffix web_docker .
This is the error we see:
2018-10-25T10:54:59.901632419Z An unhandled exception has occurred while executing the request.
2018-10-25T10:54:59.901706119Z System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).
2018-10-25T10:54:59.901714719Z at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
2018-10-25T10:54:59.901719519Z at System.Net.Http.HttpClient.GetStringAsyncCore(Task`1 getTask)
2018-10-25T10:54:59.901774720Z at TestWebApp.Pages.IndexModel.OnGetAsync() in /src/TestWebApp/Pages/Index.cshtml.cs:line 18
2018-10-25T10:54:59.901782320Z at Microsoft.AspNetCore.Mvc.RazorPages.Internal.ExecutorFactory.NonGenericTaskHandlerMethod.Execute(Object receiver, Object[] arguments)
2018-10-25T10:54:59.901786720Z at Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.InvokeHandlerMethodAsync()
2018-10-25T10:54:59.901859320Z at Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.InvokeNextPageFilterAsync()
2018-10-25T10:54:59.901867120Z at Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.Rethrow(PageHandlerExecutedContext context)
2018-10-25T10:54:59.901911520Z at Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2018-10-25T10:54:59.901927920Z at Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.InvokeInnerFilterAsync()
2018-10-25T10:54:59.901932220Z at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
2018-10-25T10:54:59.902024521Z at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
2018-10-25T10:54:59.902032421Z at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2018-10-25T10:54:59.902095221Z at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
2018-10-25T10:54:59.902103021Z at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
2018-10-25T10:54:59.902107221Z at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
2018-10-25T10:54:59.902159422Z at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
2018-10-25T10:54:59.902174122Z at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
2018-10-25T10:54:59.930285062Z Request finished in 85.9709ms 500 text/html; charset=utf-8

This information isn't really helpful because it's the same error we see on the stack trace of the web page. The Web API is failing to return the list of blog posts to the web application. So maybe something wrong is happening with the Web API itself. Let's take a look at the log with suffix newsfeed_docker .
2018-10-25T10:54:59.881446518Z An unhandled exception has occurred while executing the request.
2018-10-25T10:54:59.881562818Z StackExchange.Redis.RedisConnectionException: It was not possible to connect to the redis server(s). UnableToConnect on rediscache:6379/Interactive, Initializing, last: NONE, origin: BeginConnectAsync, outstanding: 0, last-read: 0s ago, last-write: 0s ago, unanswered-write: 783901s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 53s ago
2018-10-25T10:54:59.881571918Z at StackExchange.Redis.ConnectionMultiplexer.ConnectImplAsync(Object configuration, TextWriter log) in C:\projects\stackexchange-redis\src\StackExchange.Redis\ConnectionMultiplexer.cs:line 820
2018-10-25T10:54:59.881632919Z at TestWebApi.Controllers.NewsController.Get() in /app/Controllers/NewsController.cs:line 22
2018-10-25T10:54:59.881640719Z at lambda_method(Closure , Object )
2018-10-25T10:54:59.881644719Z at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
2018-10-25T10:54:59.881696719Z at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
2018-10-25T10:54:59.881704419Z at System.Threading.Tasks.ValueTask`1.get_Result()
2018-10-25T10:54:59.881762619Z at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
2018-10-25T10:54:59.881781119Z at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
2018-10-25T10:54:59.881785419Z at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
2018-10-25T10:54:59.881846920Z at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2018-10-25T10:54:59.881854320Z at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
2018-10-25T10:54:59.881937520Z at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
2018-10-25T10:54:59.881944820Z at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
2018-10-25T10:54:59.881948520Z at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2018-10-25T10:54:59.882008221Z at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
2018-10-25T10:54:59.882015221Z at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
2018-10-25T10:54:59.882018921Z at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
2018-10-25T10:54:59.882073921Z at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
2018-10-25T10:54:59.913042876Z Request finished in 66.4934ms 500 text/html; charset=utf-8

Now we are getting a much more meaningful error! As you can see from the description, the problem seems to be the connection between the Web API and the Redis cache. The connection to the Redis cache to retrieve the list of cached posts is failing.

What's happening here? This problem took me a while to figure out because the same multi-container architecture was working just fine on my local machine. When you deploy a solution using Docker Compose, thanks to the dedicated bridge, all the containers are hosted on the same network, so they can easily comunicate with each other using their IP address or DNS name. As such, at first I had no idea why the Web API wasn't able to communicate with the Redis cache.

Thanks to my friend and Azure guru Carlos I've been able to understand what's happening. If you remember the post about creating our multi-container application , we have learned that we can simplify the communication between multiple containers by using their name. The same concept was applied during the deployment phase , when we have set the container_name property in the Docker Compose file.

This is the configuration we have specified for the Redis cache container:
redis:
image: redis
container_name: rediscache

Since we have specified rediscache as name of the container, we have configured the Web API to connect to the Redis cache using this name. This is an excerpt of the code which we have previously wrote in the Web API controller:
[Route("api/[controller]")]
[ApiController]
public class NewsController : ControllerBase
{
// GET api/values
[HttpGet]
public async Task<ActionResult<IEnumerable<string>>> Get()
{
ConnectionMultiplexer connection = await ConnectionMultiplexer.ConnectAsync("rediscache");
var db = connection.GetDatabase();

//code to parse the XML
}
}

The connection to the rediscache container, performed by the ConnectAsync() method of the ConnectionMultiplexer class, is failing. The reason is that Azure ignores the container_name property included in the Docker Compose file, but it sets the name of the container simply using the name of the service.
In our Docker Compose file the name we have configured for the service is simply redis , so we need to change the Web API code to use the new endpoint:
[Route("api/[controller]")]
[ApiController]
public class NewsController : ControllerBase
{
// GET api/values
[HttpGet]
public async Task<ActionResult<IEnumerable<string>>> Get()
{
ConnectionMultiplexer connection = await ConnectionMultiplexer.ConnectAsync("redis");
var db = connection.GetDatabase();

//code to parse the XML
}
}

After having applied this fix, we need to create a new image and push it again to Docker Hub. At first, run the following command from the folder which contains the Web API:
docker build --rm -t qmatteoq/testwebapi:latest .

Then push it to Docker Hub using the following command:
docker push qmatteoq/testwebapi

Once it's done, go back to the Azure portal and, in the Web App, choose the Container settings section. This will bring up the same panel you have used during the creation of the web app to configure your Docker based solution. Press Browse and look again for the Docker Compose file, then press Save at the end of the page. This will trigger a new deploy of the solution. Azure will pull the updated images from Docker hub and it will spin up a new set of containers.

If you did everything well, now if you try to hit again the URL of your web app you should see the application up & running:



And if your refresh it, you should see the first item in the blog posts list changing, to demonstrate that the list of posts have been retrieved from the Redis cache and not re-downloaded from the original RSS.

What's next?


In this post we have learned how we can use Azure App Services to deploy our multi-container application on the cloud, so that it can be easily accessed also from other users, it can easily scale in case of heavy workloads, etc. Everything has been done using a PaaS service, meaning that we don't have to worry about maintaining the hardware, the virtual machine, the OS or the Docker service. We can just focus on our application.

In order to achieve this goal, however, in this post we have performed a lot of manual tasks. We had to manually push again our image once we have built it; we had to manually perform a new deploy of the Docker Compose file in order to let Azure pick the new version of the image we have published on Docker Hub; etc.
In the next post we'll see how we can automate this process thanks to Azure DevOps and Docker Hub.

Happy coding!
%3CLINGO-SUB%20id%3D%22lingo-sub-317806%22%20slang%3D%22en-US%22%3EDeploy%20a%20Docker%20multi-container%20application%20on%20Azure%20Web%20Apps%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-317806%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3EFirst%20published%20on%20MSDN%20on%20Oct%2024%2C%202018%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Fappconsult%2F2018%2F09%2F14%2Fintroduction-to-docker-deploy-a-multi-container-application%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20In%20the%20last%20post%20%3C%2FA%3E%20of%20my%20series%20about%20Docker%20we%20have%20seen%20how%2C%20thanks%20to%20Docker%20Compose%2C%20it's%20easy%20to%20deploy%20an%20application%20composed%20by%20multiple%20components%20running%20in%20different%20containers.%20%3CBR%20%2F%3E%20Thanks%20to%20Docker%20Compose%20we%20can%20run%20or%20stop%20all%20the%20containers%20which%20compose%20our%20application%20at%20the%20same%20time%20with%20a%20single%20command%3B%20additionally%2C%20the%20tool%20takes%20care%20of%20creating%20a%20dedicated%20network%20bridge%2C%20so%20that%20we%20can%20easily%20put%20them%20in%20communication%20simply%20by%20using%20the%20assigned%20IP%20address%20or%20DNS%20name.%20%3CBR%20%2F%3E%20The%20biggest%20advantage%20of%20this%20approach%20(and%2C%20generally%20speaking%2C%20of%20Docker%20containers)%20is%20that%20we%20can%20take%20this%20architecture%20and%20deploy%20it%20on%20any%20machine%20which%20hosts%20the%20Docker%20service%20and%20be%20sure%20that%20it%20will%20always%20run%20as%20expected.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20However%2C%20until%20the%20last%20post%2C%20we%20have%20always%20deployed%20our%20solutions%20based%20on%20containers%20on%20our%20local%20machine.%20It%20was%20great%20for%20testing%20and%20debugging%20purposes%2C%20but%20it%20isn't%20a%20realistic%20scenario.%20A%20real%20application%20would%20run%20on%20a%20real%20server%2C%20so%20that%20it%20can%20be%20accessed%20by%20any%20user.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20And%20which%20better%20place%20to%20host%20our%20applications%20than%20the%20cloud%3F%20Azure%20is%20a%20perfect%20match%20for%20container-based%20solutions%2C%20since%20it%20can%20quickly%20scale%20based%20on%20the%20workload.%20%3CBR%20%2F%3E%20As%20we%20have%20seen%20so%20far%2C%20Docker%20is%20just%20a%20service%20that%20can%20run%20on%20any%20Windows%20or%20Linux%20machine.%20A%20simple%20approach%20to%20host%20our%20application%20would%20be%20to%20create%20a%20Linux%20VM%20on%20Azure%2C%20install%20Docker%20and%20invoke%20our%20Docker%20Compose%20command%20on%20it.%20However%2C%20this%20solution%20has%20some%20downsides.%20Since%20we%20have%20created%20the%20VM%2C%20we%20are%20responsible%20for%20it.%20We%20need%20to%20keep%20it%20patched%2C%20up-to-date%20with%20the%20latest%20security%20features%2C%20etc.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20It%20would%20be%20much%20better%20if%20we%20could%20use%20a%20PaaS%20(Platform-As-A-Service)%20solution%3F%20Welcome%20Azure%20Web%20Apps!%20%3CBR%20%2F%3E%3CH3%20id%3D%22using-azure-web-apps-with-docker%22%20id%3D%22toc-hId-1477836548%22%20id%3D%22toc-hId-1507447038%22%3EUsing%20Azure%20Web%20Apps%20with%20Docker%3C%2FH3%3E%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapp-service%2Fapp-service-web-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Web%20Apps%20%3C%2FA%3E%20is%20an%20Azure%20service%2C%20which%20is%20part%20of%20the%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fservices%2Fapp-service%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Azure%20App%20Servic%20%3C%2FA%3E%20e%20realm%2C%20that%20can%20host%20any%20kind%20of%20web%20application.%20It's%20a%20PaaS%20service%2C%20meaning%20that%20we%20can%20focus%20on%20the%20web%20application%20hosting%2C%20without%20bothering%20about%20the%20underneath%20hardware%20and%20configuration.%20We%20can%20choose%20the%20configuration%20of%20the%20machine%20(based%20on%20the%20workload)%2C%20we%20can%20configure%20the%20application%20platform%20(for%20example%2C%20by%20choosing%20which%20version%20of%20.NET%2C%20PHP%20or%20Java%20we%20want%20to%20leverage)%2C%20but%20we%20aren't%20responsible%20for%20maintaining%20the%20underline%20platform.%20We%20don't%20have%20to%20take%20care%20of%20keeping%20the%20OS%20or%20the%20frameworks%20up-to-date.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Since%20a%20while%20Azure%20App%20Service%20has%20added%20support%20for%20Linux%20machines%2C%20meaning%20that%20we%20can%20host%20web%20apps%20on%20a%20machine%20running%20Linux%20instead%20of%20Windows.%20With%20this%20feature%20we%20get%20also%20full%20Docker%20support%2C%20for%20a%20single%20container%20or%20for%20multiple%20containers.%20%3CBR%20%2F%3E%20This%20means%20that%2C%20using%20the%20same%20Docker%20images%20and%20compose%20file%20we%20have%20built%20to%20deploy%20our%20solution%20locally%2C%20we%20can%20deploy%20our%20application%20also%20on%20Azure%20and%20immediately%20get%20all%20the%20benefits%20offered%20by%20this%20powerful%20platform.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Let's%20start!%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20First%20go%20to%20the%20%3CA%20href%3D%22https%3A%2F%2Fportal.azure.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20Azure%20portal%20%3C%2FA%3E%20and%20login%20with%20your%20account.%20Choose%20%3CSTRONG%3E%20Create%20a%20resource%20%3C%2FSTRONG%3E%20and%2C%20from%20the%20list%2C%20choose%20%3CSTRONG%3E%20Web%20App%20%3C%2FSTRONG%3E%20.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F67690i86CF92CE2601F434%22%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20You%20will%20be%20asked%20to%20setup%20your%20web%20application%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F67692i4BF73443B0801871%22%20%2F%3E%20%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3EApp%20name%20is%20a%20unique%20identifier%20for%20the%20app.%20It%20will%20be%20also%20the%20prefix%20of%20the%20default%20domain%20to%20reach%20this%20app%20from%20Internet.%20For%20example%2C%20if%20you%20call%20it%20%3CSTRONG%3E%20MyFirstDockerApp%20%3C%2FSTRONG%3E%20%2C%20you%20will%20be%20able%20to%20access%20to%20it%20using%20%3CSTRONG%3E%20%3CA%20href%3D%22https%3A%2F%2Fmyfirstdockerapp.azurewebsites.net%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20https%3A%2F%2Fmyfirstdockerapp.azurewebsites.net%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EThe%20Azure%20subscription%2C%20in%20case%20you%20have%20one%20or%20more.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EThe%20resource%20group%2C%20which%20is%20a%20way%20to%20bundle%20together%20all%20the%20services%20required%20by%20the%20web%20app%20to%20work.%20I%20suggest%20to%20create%20a%20new%20dedicated%20one%2C%20so%20that%20at%20a%20later%20stage%20you%20can%20easily%20delete%20or%20move%20all%20the%20resources.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EThe%20operating%20system.%20Choose%20%3CSTRONG%3E%20Linux%20%3C%2FSTRONG%3E%20.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EThe%20App%20Service%20plan%20%2F%20location.%20Use%20this%20option%20to%20choose%20the%20App%20Service%20plan%20you%20want%20to%20use.%20An%20App%20Service%20plan%20is%20a%20combination%20of%20location%20(in%20which%20Azure%20region%20you%20want%20to%20deploy%20the%20app)%20and%20the%20pricing%20tier%20(which%20reflects%20the%20hardware%20features%20of%20the%20hosting%20machine).%20At%20the%20top%20you%20will%20notice%20that%20the%20pricing%20tiers%20are%20split%20into%20three%20different%20categories%3A%20Dev%20%2F%20Test%2C%20Production%20and%20Isolated.%20Since%20we%20are%20in%20testing%20phase%2C%20feel%20free%20to%20choose%20one%20of%20the%20plans%20under%20the%20first%20option%2C%20which%20are%20free%20or%20really%20cheap.%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%20We%20have%20left%20one%20option%20behind%2C%20because%20it's%20the%20critical%20one%20we%20need%20for%20our%20workload.%20Under%20%3CSTRONG%3E%20Publish%20%3C%2FSTRONG%3E%20%2C%20you%20can%20choose%20%3CSTRONG%3E%20Code%20%3C%2FSTRONG%3E%20or%20%3CSTRONG%3E%20Docker%20Image%20%3C%2FSTRONG%3E%20.%20Once%20you%20choose%20the%20second%20option%2C%20you%20will%20see%20at%20the%20bottom%20a%20new%20field%20called%20%3CSTRONG%3E%20Configure%20container%20%3C%2FSTRONG%3E%20.%20By%20clicking%20on%20it%20you%20will%20expand%2C%20at%20the%20right%2C%20a%20new%20panel%20where%20to%20specify%20the%20configuration%20of%20your%20containers%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F67694iE86E55F1F362CA51%22%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20You%20have%20three%20options%3A%20%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3E%3CSTRONG%3ESingle%20container%20%3C%2FSTRONG%3E%20can%20be%20used%20to%20deploy%20a%20single%20application%20running%20in%20a%20single%20container%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CSTRONG%3EDocker%20Compose%20%3C%2FSTRONG%3E%20can%20be%20used%20to%20deploy%20a%20solution%20based%20on%20multiple%20containers%20using%20the%20Docker%20Compose%20file%20format.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CSTRONG%3EKubernetes%20%3C%2FSTRONG%3E%20achieves%20the%20same%20goal%20of%20the%20previous%20option%2C%20but%20using%20the%20Kubernetes%20file%20format%20to%20describe%20the%20containers.%20In%20case%20you%20never%20heard%20of%20it%2C%20Kubernetes%20is%20a%20very%20popular%20technology%20to%20orchestrate%20containers%20created%20by%20Google.%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%20Regardless%20of%20the%20choice%2C%20you%20will%20be%20able%20to%20use%20different%20image%20sources%3A%20%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3E%3CSTRONG%3EQuickstart%20%3C%2FSTRONG%3E%20allows%20to%20quickly%20deploy%20sample%20solutions%20to%20test%20the%20Azure%20App%20Service%20platform.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CSTRONG%3EAzure%20Container%20Registry%20%3C%2FSTRONG%3E%20is%20a%20platform%20provided%20by%20Azure%20to%20host%20your%20own%20images.%20Think%20of%20it%20like%20your%20own%20personal%20Docker%20Hub%20repository.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CSTRONG%3EDocker%20Hub%20%3C%2FSTRONG%3E%20is%20the%20official%20Docker%20repository%20we%20have%20learned%20to%20use%20in%20the%20previous%20posts.%20From%20here%20you%20can%20pull%20all%20the%20public%20images%20released%20by%20developers%20and%20companies%20from%20all%20around%20the%20globe.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3E%3CSTRONG%3EPrivate%20Registry%20%3C%2FSTRONG%3E%20is%20the%20option%20to%20choose%20in%20case%20you're%20hosting%20your%20images%20on%20your%20own%20private%20repository.%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%20Our%20scenario%20is%20a%20multi-container%20solution%20based%20on%20images%20coming%20from%20Docker%20Hub.%20If%20you%20remember%20%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Fappconsult%2F2018%2F09%2F11%2Ffirst-steps-with-docker-dockerizing-your-first-application%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20one%20of%20the%20previous%20posts%20%3C%2FA%3E%20%2C%20we%20have%20pushed%20the%20images%20we%20have%20built%20for%20our%20web%20application%20and%20our%20web%20API%20to%20Docker%20Hub.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Let's%20choose%20%3CSTRONG%3E%20Docker%20Compose%20%3C%2FSTRONG%3E%20and%20then%20%3CSTRONG%3E%20Docker%20Hub%20%3C%2FSTRONG%3E%20as%20%3CSTRONG%3E%20Image%20source%20%3C%2FSTRONG%3E%20.%20We%20have%20published%20our%20images%20as%20public%2C%20so%20leave%20%3CSTRONG%3E%20Public%20%3C%2FSTRONG%3E%20as%20%3CSTRONG%3E%20Repository%20Access%20%3C%2FSTRONG%3E%20.%20In%20the%20%3CSTRONG%3E%20Configuration%20File%20%3C%2FSTRONG%3E%20field%20press%20%3CSTRONG%3E%20Browse%20%3C%2FSTRONG%3E%20and%20look%20for%20the%20%3CSTRONG%3E%20docker-compose.yml%20%3C%2FSTRONG%3E%20file%20we%20have%20built%20%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Fappconsult%2F2018%2F09%2F14%2Fintroduction-to-docker-deploy-a-multi-container-application%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20in%20a%20previous%20post%20%3C%2FA%3E%20.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20You%20will%20see%2C%20in%20the%20%3CSTRONG%3E%20Configuration%20%3C%2FSTRONG%3E%20area%2C%20the%20content%20of%20the%20YML%20file.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F67696i2663120002F4BD68%22%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Press%20%3CSTRONG%3E%20Apply%20%3C%2FSTRONG%3E%20and%20you%20will%20be%20redirected%20to%20the%20Web%20App%20configuration%20page.%20This%20time%20the%20%3CSTRONG%3E%20Configure%20container%20%3C%2FSTRONG%3E%20field%20should%20be%20reported%20as%20%3CSTRONG%3E%20Complete%20%3C%2FSTRONG%3E%20.%20Press%20%3CSTRONG%3E%20Create%20%3C%2FSTRONG%3E%20at%20the%20bottom%20of%20the%20section%20to%20start%20the%20creation%20of%20the%20web%20app.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20The%20web%20application%20will%20be%20now%20deployed%20and%2C%20under%20the%20hood%2C%20Azure%20will%20pull%20the%20images%20we%20have%20specified%20in%20the%20Docker%20Compose%20file%20(qmatteoq%5Ctestwebapp%2C%20qmatteoq%5Ctestwebapi%20and%20redis)%20and%20will%20spin%20a%20container%20for%20each%20of%20them.%20Azure%20is%20smart%20enough%20to%20understand%20that%20the%20service%20called%20%3CSTRONG%3E%20web%20%3C%2FSTRONG%3E%20is%20the%20only%20one%20for%20which%20we're%20exposing%20the%2080%20port.%20As%20such%2C%20this%20container%20will%20be%20the%20one%20exposed%20directly%20through%20the%2080%20port%20of%20the%20URL%20that%20has%20been%20assigned%20to%20the%20our%20App%20Service.%20%3CBR%20%2F%3E%3CH3%20id%3D%22everything-is-awesome-more-or-less%22%20id%3D%22toc-hId--1074320413%22%20id%3D%22toc-hId--1044709923%22%3EEverything%20is%20awesome...%20more%20or%20less%3C%2FH3%3E%3CBR%20%2F%3E%20Let's%20give%20a%20try%20to%20our%20deployment.%20Open%20the%20browser%20and%20point%20it%20to%20the%20URL%20which%20was%20assigned%20your%20app%20service.%20You%20should%20see...%20this%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F67698i6B965F69B6263836%22%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Well%2C%20this%20isn't%20a%20pleasant%20surprise.%20Something%20bad%20is%20happening.%20Specifically%2C%20based%20on%20the%20stack%20trace%2C%20it%20seems%20that%20our%20web%20application%20is%20failing%20to%20communicate%20with%20the%20Web%20API.%20The%20%3CSTRONG%3E%20GetStringAsync()%20%3C%2FSTRONG%3E%20method%20of%20the%20%3CSTRONG%3E%20HttpClient%20%3C%2FSTRONG%3E%20%2C%20which%20we're%20using%20to%20retrieve%20the%20list%20of%20blog%20posts%20from%20the%20Web%20API%2C%20is%20failing.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Is%20it%20possible%20to%20get%20more%20details%3F%20Sure%2C%20but%20first%20we%20need%20to%20enable%20some%20logging.%20Move%20to%20the%20%3CSTRONG%3E%20Diagnostic%20logs%20%3C%2FSTRONG%3E%20section%20of%20your%20web%20app%20and%20turn%20it%20on%20by%20choosing%20%3CSTRONG%3E%20File%20System%20%3C%2FSTRONG%3E%20.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F67699i8BF9533334B1111C%22%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Now%20try%20to%20reload%20again%20the%20website%2C%20in%20order%20to%20reproduce%20the%20error.%20Now%20we%20should%20have%20some%20logging%20in%20the%20file%20system%20of%20the%20web%20application.%20The%20easiest%20way%20to%20access%20them%20is%20to%20choose%20%3CSTRONG%3E%20Advanced%20Tools%20%3C%2FSTRONG%3E%20from%20the%20%3CSTRONG%3E%20Development%20tools%20%3C%2FSTRONG%3E%20section%20of%20the%20web%20app.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F67701i2CE738F7B35DC4A9%22%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Press%20the%20%3CSTRONG%3E%20Go%20%3C%2FSTRONG%3E%20button%20to%20open%20Kudu%2C%20which%20is%20a%20diagnostic%20web%20interface%20for%20your%20application.%20Typically%2C%20Kudu%20is%20available%20at%20the%20same%20URL%20of%20the%20main%20application%2C%20but%20with%20the%20prefix%20%3CSTRONG%3E%20scm%20%3C%2FSTRONG%3E%20between%20the%20app%20name%20and%20the%20domain.%20For%20example%2C%20if%20your%20application%20is%20hosted%20at%20%3CA%20href%3D%22https%3A%2F%2Fmydockerwebapp.azurewebsites.net%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20https%3A%2F%2Fmydockerwebapp.azurewebsites.net%20%3C%2FA%3E%20%2C%20the%20Kudu%20interface%20will%20be%20available%20at%20%3CA%20href%3D%22https%3A%2F%2Fmydockerwebapp.scm.azurewebsites.net%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20https%3A%2F%2Fmydockerwebapp.scm.azurewebsites.net%20%3C%2FA%3E%20.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20As%20you%20can%20see%20in%20the%20web%20interface%2C%20one%20of%20the%20available%20REST%20API%20is%20called%20%3CSTRONG%3E%20Current%20Docker%20logs%20%3C%2FSTRONG%3E%20%3A%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F67702iEF253A36515987F2%22%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Click%20on%20the%20%3CSTRONG%3E%20Download%20as%20zip%20%3C%2FSTRONG%3E%20button%20to%20download%20a%20compressed%20file%2C%20which%20will%20contain%20multiple%20log%20files%3A%20a%20generic%20one%20for%20the%20Docker%20service%20and%20a%20specific%20one%20for%20each%20container%20that%20has%20been%20created.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F67703iB8060694B0C52E95%22%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Let's%20start%20by%20opening%20the%20one%20related%20to%20the%20web%20application%2C%20which%20ends%20with%20the%20suffix%20%3CSTRONG%3E%20web_docker%20%3C%2FSTRONG%3E%20.%20%3CBR%20%2F%3E%20This%20is%20the%20error%20we%20see%3A%20%3CBR%20%2F%3E%3CCODE%3E%0A%20%20%202018-10-25T10%3A54%3A59.901632419Z%20%20%20%20%20%20%20An%20unhandled%20exception%20has%20occurred%20while%20executing%20the%20request.%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.901706119Z%20System.Net.Http.HttpRequestException%3A%20Response%20status%20code%20does%20not%20indicate%20success%3A%20500%20(Internal%20Server%20Error).%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.901714719Z%20%20%20%20at%20System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.901719519Z%20%20%20%20at%20System.Net.Http.HttpClient.GetStringAsyncCore(Task%601%20getTask)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.901774720Z%20%20%20%20at%20TestWebApp.Pages.IndexModel.OnGetAsync()%20in%20%2Fsrc%2FTestWebApp%2FPages%2FIndex.cshtml.cs%3Aline%2018%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.901782320Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.RazorPages.Internal.ExecutorFactory.NonGenericTaskHandlerMethod.Execute(Object%20receiver%2C%20Object%5B%5D%20arguments)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.901786720Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.InvokeHandlerMethodAsync()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.901859320Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.InvokeNextPageFilterAsync()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.901867120Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.Rethrow(PageHandlerExecutedContext%20context)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.901911520Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.Next(State%26amp%3B%20next%2C%20Scope%26amp%3B%20scope%2C%20Object%26amp%3B%20state%2C%20Boolean%26amp%3B%20isCompleted)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.901927920Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker.InvokeInnerFilterAsync()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.901932220Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.902024521Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext%20context)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.902032421Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State%26amp%3B%20next%2C%20Scope%26amp%3B%20scope%2C%20Object%26amp%3B%20state%2C%20Boolean%26amp%3B%20isCompleted)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.902095221Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.902103021Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.902107221Z%20%20%20%20at%20Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext%20httpContext)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.902159422Z%20%20%20%20at%20Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext%20context)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.902174122Z%20%20%20%20at%20Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext%20context)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.930285062Z%20%20%20%20%20%20%20Request%20finished%20in%2085.9709ms%20500%20text%2Fhtml%3B%20charset%3Dutf-8%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20This%20information%20isn't%20really%20helpful%20because%20it's%20the%20same%20error%20we%20see%20on%20the%20stack%20trace%20of%20the%20web%20page.%20The%20Web%20API%20is%20failing%20to%20return%20the%20list%20of%20blog%20posts%20to%20the%20web%20application.%20So%20maybe%20something%20wrong%20is%20happening%20with%20the%20Web%20API%20itself.%20Let's%20take%20a%20look%20at%20the%20log%20with%20suffix%0A%20%20%3CSTRONG%3E%0A%20%20%20newsfeed_docker%0A%20%20%3C%2FSTRONG%3E%0A%20%20.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%202018-10-25T10%3A54%3A59.881446518Z%20%20%20%20%20%20%20An%20unhandled%20exception%20has%20occurred%20while%20executing%20the%20request.%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881562818Z%20StackExchange.Redis.RedisConnectionException%3A%20It%20was%20not%20possible%20to%20connect%20to%20the%20redis%20server(s).%20UnableToConnect%20on%20rediscache%3A6379%2FInteractive%2C%20Initializing%2C%20last%3A%20NONE%2C%20origin%3A%20BeginConnectAsync%2C%20outstanding%3A%200%2C%20last-read%3A%200s%20ago%2C%20last-write%3A%200s%20ago%2C%20unanswered-write%3A%20783901s%20ago%2C%20keep-alive%3A%2060s%2C%20state%3A%20Connecting%2C%20mgr%3A%2010%20of%2010%20available%2C%20last-heartbeat%3A%20never%2C%20global%3A%2053s%20ago%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881571918Z%20%20%20%20at%20StackExchange.Redis.ConnectionMultiplexer.ConnectImplAsync(Object%20configuration%2C%20TextWriter%20log)%20in%20C%3A%5Cprojects%5Cstackexchange-redis%5Csrc%5CStackExchange.Redis%5CConnectionMultiplexer.cs%3Aline%20820%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881632919Z%20%20%20%20at%20TestWebApi.Controllers.NewsController.Get()%20in%20%2Fapp%2FControllers%2FNewsController.cs%3Aline%2022%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881640719Z%20%20%20%20at%20lambda_method(Closure%20%2C%20Object%20)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881644719Z%20%20%20%20at%20Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881696719Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper%20mapper%2C%20ObjectMethodExecutor%20executor%2C%20Object%20controller%2C%20Object%5B%5D%20arguments)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881704419Z%20%20%20%20at%20System.Threading.Tasks.ValueTask%601.get_Result()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881762619Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881781119Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881785419Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext%20context)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881846920Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State%26amp%3B%20next%2C%20Scope%26amp%3B%20scope%2C%20Object%26amp%3B%20state%2C%20Boolean%26amp%3B%20isCompleted)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881854320Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881937520Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881944820Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext%20context)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.881948520Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State%26amp%3B%20next%2C%20Scope%26amp%3B%20scope%2C%20Object%26amp%3B%20state%2C%20Boolean%26amp%3B%20isCompleted)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.882008221Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.882015221Z%20%20%20%20at%20Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.882018921Z%20%20%20%20at%20Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext%20httpContext)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.882073921Z%20%20%20%20at%20Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext%20context)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%202018-10-25T10%3A54%3A59.913042876Z%20%20%20%20%20%20%20Request%20finished%20in%2066.4934ms%20500%20text%2Fhtml%3B%20charset%3Dutf-8%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Now%20we%20are%20getting%20a%20much%20more%20meaningful%20error!%20As%20you%20can%20see%20from%20the%20description%2C%20the%20problem%20seems%20to%20be%20the%20connection%20between%20the%20Web%20API%20and%20the%20Redis%20cache.%20The%20connection%20to%20the%20Redis%20cache%20to%20retrieve%20the%20list%20of%20cached%20posts%20is%20failing.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20What's%20happening%20here%3F%20This%20problem%20took%20me%20a%20while%20to%20figure%20out%20because%20the%20same%20multi-container%20architecture%20was%20working%20just%20fine%20on%20my%20local%20machine.%20When%20you%20deploy%20a%20solution%20using%20Docker%20Compose%2C%20thanks%20to%20the%20dedicated%20bridge%2C%20all%20the%20containers%20are%20hosted%20on%20the%20same%20network%2C%20so%20they%20can%20easily%20comunicate%20with%20each%20other%20using%20their%20IP%20address%20or%20DNS%20name.%20As%20such%2C%20at%20first%20I%20had%20no%20idea%20why%20the%20Web%20API%20wasn't%20able%20to%20communicate%20with%20the%20Redis%20cache.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Thanks%20to%20my%20friend%20and%20Azure%20guru%0A%20%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2FCJ_Aliaga%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%0A%20%20%20Carlos%0A%20%20%3C%2FA%3E%0A%20%20I've%20been%20able%20to%20understand%20what's%20happening.%20If%20you%20remember%0A%20%20%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Fappconsult%2F2018%2F09%2F11%2Fintroduction-to-docker-create-a-multi-container-application%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%0A%20%20%20the%20post%20about%20creating%20our%20multi-container%20application%0A%20%20%3C%2FA%3E%0A%20%20%2C%20we%20have%20learned%20that%20we%20can%20simplify%20the%20communication%20between%20multiple%20containers%20by%20using%20their%20name.%20The%20same%20concept%20was%20applied%0A%20%20%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Fappconsult%2F2018%2F09%2F14%2Fintroduction-to-docker-deploy-a-multi-container-application%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%0A%20%20%20during%20the%20deployment%20phase%0A%20%20%3C%2FA%3E%0A%20%20%2C%20when%20we%20have%20set%20the%0A%20%20%3CSTRONG%3E%0A%20%20%20container_name%0A%20%20%3C%2FSTRONG%3E%0A%20%20property%20in%20the%20Docker%20Compose%20file.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20This%20is%20the%20configuration%20we%20have%20specified%20for%20the%20Redis%20cache%20container%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20redis%3A%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20image%3A%20redis%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20container_name%3A%20rediscache%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Since%20we%20have%20specified%0A%20%20%3CSTRONG%3E%0A%20%20%20rediscache%0A%20%20%3C%2FSTRONG%3E%0A%20%20as%20name%20of%20the%20container%2C%20we%20have%20configured%20the%20Web%20API%20to%20connect%20to%20the%20Redis%20cache%20using%20this%20name.%20This%20is%20an%20excerpt%20of%20the%20code%20which%20we%20have%20previously%20wrote%20in%20the%20Web%20API%20controller%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20%5BRoute(%22api%2F%5Bcontroller%5D%22)%5D%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%5BApiController%5D%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20public%20class%20NewsController%20%3A%20ControllerBase%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%7B%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%2F%2F%20GET%20api%2Fvalues%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%5BHttpGet%5D%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20public%20async%20Task%3CACTIONRESULT%3E%3CIENUMERABLE%3E%3CSTRING%3E%26gt%3B%26gt%3B%20Get()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%7B%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20ConnectionMultiplexer%20connection%20%3D%20await%20ConnectionMultiplexer.ConnectAsync(%22rediscache%22)%3B%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20var%20db%20%3D%20connection.GetDatabase()%3B%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%2F%2Fcode%20to%20parse%20the%20XML%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%7D%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%7D%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%3C%2FSTRING%3E%3C%2FIENUMERABLE%3E%3C%2FACTIONRESULT%3E%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20The%20connection%20to%20the%0A%20%20%3CSTRONG%3E%0A%20%20%20rediscache%0A%20%20%3C%2FSTRONG%3E%0A%20%20container%2C%20performed%20by%20the%0A%20%20%3CSTRONG%3E%0A%20%20%20ConnectAsync()%0A%20%20%3C%2FSTRONG%3E%0A%20%20method%20of%20the%0A%20%20%3CSTRONG%3E%0A%20%20%20ConnectionMultiplexer%0A%20%20%3C%2FSTRONG%3E%0A%20%20class%2C%20is%20failing.%20The%20reason%20is%20that%20Azure%20ignores%20the%0A%20%20%3CSTRONG%3E%0A%20%20%20container_name%0A%20%20%3C%2FSTRONG%3E%0A%20%20property%20included%20in%20the%20Docker%20Compose%20file%2C%20but%20it%20sets%20the%20name%20of%20the%20container%20simply%20using%20the%20name%20of%20the%20service.%0A%20%20%3CBR%20%2F%3E%0A%20%20In%20our%20Docker%20Compose%20file%20the%20name%20we%20have%20configured%20for%20the%20service%20is%20simply%0A%20%20%3CSTRONG%3E%0A%20%20%20redis%0A%20%20%3C%2FSTRONG%3E%0A%20%20%2C%20so%20we%20need%20to%20change%20the%20Web%20API%20code%20to%20use%20the%20new%20endpoint%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20%5BRoute(%22api%2F%5Bcontroller%5D%22)%5D%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%5BApiController%5D%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20public%20class%20NewsController%20%3A%20ControllerBase%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%7B%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%2F%2F%20GET%20api%2Fvalues%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%5BHttpGet%5D%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20public%20async%20Task%3CACTIONRESULT%3E%3CIENUMERABLE%3E%3CSTRING%3E%26gt%3B%26gt%3B%20Get()%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%7B%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20ConnectionMultiplexer%20connection%20%3D%20await%20ConnectionMultiplexer.ConnectAsync(%22redis%22)%3B%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20var%20db%20%3D%20connection.GetDatabase()%3B%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%2F%2Fcode%20to%20parse%20the%20XML%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%7D%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%7D%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%3C%2FSTRING%3E%3C%2FIENUMERABLE%3E%3C%2FACTIONRESULT%3E%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20After%20having%20applied%20this%20fix%2C%20we%20need%20to%20create%20a%20new%20image%20and%20push%20it%20again%20to%20Docker%20Hub.%20At%20first%2C%20run%20the%20following%20command%20from%20the%20folder%20which%20contains%20the%20Web%20API%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20docker%20build%20--rm%20-t%20qmatteoq%2Ftestwebapi%3Alatest%20.%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Then%20push%20it%20to%20Docker%20Hub%20using%20the%20following%20command%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20docker%20push%20qmatteoq%2Ftestwebapi%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Once%20it's%20done%2C%20go%20back%20to%20the%20Azure%20portal%20and%2C%20in%20the%20Web%20App%2C%20choose%20the%0A%20%20%3CSTRONG%3E%0A%20%20%20Container%20settings%0A%20%20%3C%2FSTRONG%3E%0A%20%20section.%20This%20will%20bring%20up%20the%20same%20panel%20you%20have%20used%20during%20the%20creation%20of%20the%20web%20app%20to%20configure%20your%20Docker%20based%20solution.%20Press%0A%20%20%3CSTRONG%3E%0A%20%20%20Browse%0A%20%20%3C%2FSTRONG%3E%0A%20%20and%20look%20again%20for%20the%20Docker%20Compose%20file%2C%20then%20press%0A%20%20%3CSTRONG%3E%0A%20%20%20Save%0A%20%20%3C%2FSTRONG%3E%0A%20%20at%20the%20end%20of%20the%20page.%20This%20will%20trigger%20a%20new%20deploy%20of%20the%20solution.%20Azure%20will%20pull%20the%20updated%20images%20from%20Docker%20hub%20and%20it%20will%20spin%20up%20a%20new%20set%20of%20containers.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20If%20you%20did%20everything%20well%2C%20now%20if%20you%20try%20to%20hit%20again%20the%20URL%20of%20your%20web%20app%20you%20should%20see%20the%20application%20up%20%26amp%3B%20running%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F67704iA331A3B2541108DC%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20And%20if%20your%20refresh%20it%2C%20you%20should%20see%20the%20first%20item%20in%20the%20blog%20posts%20list%20changing%2C%20to%20demonstrate%20that%20the%20list%20of%20posts%20have%20been%20retrieved%20from%20the%20Redis%20cache%20and%20not%20re-downloaded%20from%20the%20original%20RSS.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CH3%20id%3D%22whats-next%22%20id%3D%22toc-hId-668489922%22%20id%3D%22toc-hId-698100412%22%3E%0A%20%20%20What's%20next%3F%0A%20%20%3C%2FH3%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20In%20this%20post%20we%20have%20learned%20how%20we%20can%20use%20Azure%20App%20Services%20to%20deploy%20our%20multi-container%20application%20on%20the%20cloud%2C%20so%20that%20it%20can%20be%20easily%20accessed%20also%20from%20other%20users%2C%20it%20can%20easily%20scale%20in%20case%20of%20heavy%20workloads%2C%20etc.%20Everything%20has%20been%20done%20using%20a%20PaaS%20service%2C%20meaning%20that%20we%20don't%20have%20to%20worry%20about%20maintaining%20the%20hardware%2C%20the%20virtual%20machine%2C%20the%20OS%20or%20the%20Docker%20service.%20We%20can%20just%20focus%20on%20our%20application.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20In%20order%20to%20achieve%20this%20goal%2C%20however%2C%20in%20this%20post%20we%20have%20performed%20a%20lot%20of%20manual%20tasks.%20We%20had%20to%20manually%20push%20again%20our%20image%20once%20we%20have%20built%20it%3B%20we%20had%20to%20manually%20perform%20a%20new%20deploy%20of%20the%20Docker%20Compose%20file%20in%20order%20to%20let%20Azure%20pick%20the%20new%20version%20of%20the%20image%20we%20have%20published%20on%20Docker%20Hub%3B%20etc.%0A%20%20%3CBR%20%2F%3E%0A%20%20In%20the%20next%20post%20we'll%20see%20how%20we%20can%20automate%20this%20process%20thanks%20to%20Azure%20DevOps%20and%20Docker%20Hub.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Happy%20coding!%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-317806%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Oct%2024%2C%202018%20In%20the%20last%20post%20of%20my%20series%20about%20Docker%20we%20have%20seen%20how%2C%20thanks%20to%20Docker%20Compose%2C%20it's%20easy%20to%20deploy%20an%20application%20composed%20by%20multiple%20components%20running%20in%20different%20containers.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-317806%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20App%20Service%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDocker%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Jan 15 2019 03:15 PM
Updated by: