Road To AZ-204 - Creating Azure App Service Web Apps

Introduction

 
This article's intention is to explain the main skills measured in this sub-topic of the AZ-204 Certification. The main topic here is Azure Web Apps and we are going through creating, deploying, logging, auto-scaling, and configuring Azure Web Apps. Those techniques will have their fundamentals explained here, alongside a practical example.
This certification is very extensive and this article approaches only the main topics, make sure you know those components deeply before taking the exam. Another great tip is doing exam simulators before the official exam in order to validate your knowledge.
 

What is the Certification AZ-204 - Developing Solutions for Microsoft Azure?

 
The AZ-204 - Developing Solutions for Microsoft Azure certification measures designing, building, testing, and maintaining skills of an application and/or service in Microsoft Azure Cloud environment. It approaches, among others, the following components:
  • Azure Virtual Machines
  • Docker
  • Azure Containers
  • Service Web App
  • Azure Functions
  • Cosmos DB
  • Azure Storage
  • Azure AD
  • Azure Key Vault
  • Azure Managed Identities
  • Azure Redis Cache
  • Azure Logic App
  • Azure Event Grid
  • Azure Event Hub
  • Azure Notification Hub
  • Azure Service Bus
  • Azure Queue Storage
 
Target Audience
 
Any IT professional willing to improve his knowledge in Microsoft Azure is encouraged to take this certification, it is a great way to measure your skills within trending technologies. But, some groups of professionals are keener to take maximum advantage of it:
  • Azure Developers, with at least 1 year of experience with Microsoft Azure;
  • Experienced Software Developers, looking for an Architect position in a hybrid environment;
  • Software Developers, working to move applications to the cloud environment.
Skills Measured
 
According to today's date, the skills that are measured in the exam are split as follows:
  • Develop Azure compute solutions (25-30%)
  • Develop for Azure storage (10-15%)
    • Develop solutions that use Cosmos DB storage
    • Develop solutions that use blob storage
  • Implement Azure security (15-20%)
    • Implement user authentication and authorization
    • Implement secure cloud solutions
  • Monitor, troubleshoot, and optimize Azure solutions (10-15%)
    • Integrate caching and content delivery within solutions
    • Instrument solutions to support monitoring and logging
  • Connect to and consume Azure services and third-party services (25- 30%)
    • Develop an App Service Logic App
    • Implement API Management
    • Develop event-based solutions
    • Develop message-based solutions
Updated skills can be found in the AZ - 204 Measured Skills Website.
 

Benefits of Getting Certified

 
The main benefit here is having a worldwide recognized certification that proves that you have knowledge of this topic. Among intrinsic and extrinsic benefits, we have:
  • Higher growth potential, as certifications are a big plus;
  • Discounts and deals in Microsoft products and partners, like PluralSight and UpWork;
  • MCP Newsletters, with trending technologies;
  • Higher exposure on LinkedIn, as recruiters usually search for specific certifications;
  • Higher salary, you will be more valuable to your company;
  • Unique happiness when getting the result and you were approved, knowing that all your efforts were worth it;
 

Main skills Measured by this Topic

 
What is an Azure Web App?
 
An Azure Web App is an Azure Service focused on Web Applications, you may deploy your Web Applications and Rest APIs in .NET, .NET Core, Java, Ruby, Node.js, PHP, or Python in a Windows or Linux environment paying only for the used resources. Azure Web Apps are great if you do not mind about the website infrastructure and your only concern is to have your Web App running online because Azure offers your many built-in infrastructure features as:
  • Security
  • Load Balancing
  • Autoscaling
  • Automated Management
  • Easy and fast integration with Azure DevOps
 
SKUs and Sizes
 
Azure App Service offers different types of Skus in order to attend different types of needs. It has since free shared SKUs to Isolated Service Plans, where you have a range of different sizes. You may check the list of available combinations of Skus and Sizes below, according to the Virtual Machine operational system that hosts your Azure App Service.
Runtime Stack
 
Azure App Service hosts applications running in the main technology stack, like .NET, .NET Core, Java, Ruby, Node.js, PHP, or Python
 
Why diagnostics logging?
 
Diagnostics logging is a vital part of any Web Application operation, with logs you may troubleshoot exceptions, non-exception errors, alerts, warnings, and also, track the user experience in order to improve it. 
 
With Azure Diagnostics Logging you may log:
  • Application events generated by your app;
  • Web Server logging, with a raw version of requests made to your app. Only available for the Windows platform.
  • Detailed Error Pages, saving copies of the error pages presented to your user. Only available for the Windows platform.
  • Failed request tracing, with detailed information regarding failed requests. Only available for the Windows platform.
  • Deployment logging, logging detailed information about the deployment process in order to troubleshoot when a deployment fails. 
 
What is AutoScale?
 
Autoscaling is the process of adjusting a server infrastructure capability in order to fulfill incoming requests from your web application. It usually takes seconds for the changes to take effect, and can be done automatically according to pre-configured metrics. It does not need any new deploy or coding. 
 
There are 2 options for scaling an app:
  1. Horizontal: when you add/remove web servers from your load balancer. Example: increasing from 1 Virtual Machine to 3 Virtual Machines during peak hours.
  2. Vertical: adding/removing resources from your web servers, such as CPU, memory, or storage. Example: increase your storage capacity in order to store more logs.
 
Configuring Azure Web App Settings
 
Your Azure Web Apps settings can be easily configured through Azure CLI or Azure Portal, with the possibility to edit in bulk through the Azure Portal. The main settings that may be configured for your Azure Web App are the following:
  • SSL, to have a secure and encrypted communication channel
  • API Settings, like technology stack or platform settings
  • APP Settings, to override your configs stored on the Web.Config
  • Connection Strings, in order to do not have it written on the Web.Config
  • Default Documents, displaying default web pages when accessing the root of your Website URL
  • Path Mappings, configuring settings according to the user OS
 
Creating an Azure App Service Web App 
Though Visual Studio
 
Right Click on the Web Project and click on Publish. Then, select Azure and click Next.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Select App Service. Here we are going to use the Azure App Service ( Windows ). 
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Create a new Azure App Service
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Select your App Service Name, Subscription, Resource Group, and Hosting Plan. You can also create a new Resource Group or Hosting Plan to host your Azure App Service. 
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
After Azure validates your input data, select the recently created Azure App Service, and click finish. A new publish profile will be visible and your Azure Web App is already created.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Through Azure Portal
 
Select the Web App Resource
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Select your Web App Settings like Name, Resource Group, Runtime Stack, Operating System, Region, and App Service Plan. You can also configure Application Insights and tags here and then click on Review + create.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
After Azure runs its validation, click on Create. After a successful deployment, go to your recently created resource.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
If you check on your App Service URL, you can see that it is already online with Azure Default Empty Template. 
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Enabling diagnostics logging
 
Go to your App Service and then, under Monitoring, select App Service logs.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Log files location
  • Linux/container apps: https://<app-name>.scm.azurewebsites.net/api/logs/docker/zip
  • Windows apps: https://<app-name>.scm.azurewebsites.net/api/dump
Example for Windows apps,
 
https://netcorecalculator20201013202205.scm.azurewebsites.net/api/dump 
 
Application logging
 
You may log your files to a Filesystem or to a Blob. For storing Application logs in blobs, you need to select an Azure Storage Account.
 
You have to select the level of logs to be stored and for Application Logging using Blob, you also have to set retention days to purge old files in order to clean space.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Web Server logging 
 
Log into Azure Storage. You need to configure your Azure Storage account that will store the logs alongside the logs retention period.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Log into the File System. You have to select the quota limit of logs to be stored and also the retention period.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Detailed Error Logs
 
It is enabled here but you need to configure the logs in your code.
 
Road To AZ-204 - Creating Azure App Service Web Apps 
Failed Request Traces
 
Very simple to be enabled
Road To AZ-204 - Creating Azure App Service Web Apps
 
Streaming Logs 
 
Go to your App Service and then, under Monitoring, select Log Stream. You may select to see Application logs or Web Server Logs
 
Road To AZ-204 - Creating Azure App Service Web Apps 
 
Deploying code to a web app 
 
Through Visual Studio
 
Right-click on the Web App Project and click on publish, you will be redirected to your Publish Profile. Validate your settings and click on Publish.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
After deploy success, you will be redirected to your new Azure App Service.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 

Configuring web app settings including SSL, API, and connection strings

 
Configuring your API and APP Settings and your Connection Strings and Application Maps
 
Go to your App Service and then to Configuration 
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Application Settings, grouped by Key-Value pairs.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Connection Strings, with name, value, and database type.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
General Settings, like technology stack, platform settings, remote debugging, and client certificates.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Default Documents, to be displayed in the root of your Website URL
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Path Mappings, to configure your handler mappings and virtual applications/directories.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Configuring SSL
 
Go to your App Service and then TSL/SSL settings.
 
Here you can configure your Web App bindings, import your existing certificates, or buy a new certificate.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Azure App Service Scaling 
 
In all sub-topics, here we are going to be talking about horizontal scaling, which means that we are going to upgrade the number of instances that host our Web App. 
  • For horizontal scaling, or scaling out, go to your App Service and under Settings select Scale-out
  • For vertical scaling, or scaling up, go to your App Service and under Settings select Scale-up
Scaling Manually
 
Change the number of instances and click on save.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
AutoScaling

By Scheduled periodicity, operational and system metrics. Select Scale based on a metric.
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Instance limits
 
Have the minimum, maximum, and default amount of instances to be running according to your rules. According to your scaling rules your number of running instances is going to float from maximum to minimum, staying in the default if no rule is triggered.
 
Schedule 
 
You may schedule your rule to be executed in a specific range of dates or to be repeated every week on specific weekdays. You can also configure the timezone and range of time where your scaling rules will be applied.
 
Scaling Rules
 
Road To AZ-204 - Creating Azure App Service Web Apps
 
Criteria
 
Here we define the criteria that have to be met in order to take any scaling action:
  • Time Aggregation defines the range of time that will be used in order to aggregate the metrics. For example, Time Aggregation = “Average” should aggregate the sampled metrics by taking the average.
  • Metric Name defines the name of the metric used to evaluate these criteria.
  • Time Grain Statistics defines the metric sampling type.
  • The operator defines the comparison operator.
  • The threshold defines the target value to trigger this scaling criterion.
  • Duration defines the amount of time the scale criteria will look back.
Action
 
Here we define the action that will be executed when the criteria are met:
  • Operation defines which type of operation we want to execute, like increasing or decreasing the instance count.
  • Instance count defines the number of instances that will be increased or decreased.
  • Cooldown defines the waiting time in order to execute another action.
External References