Reader small image

You're reading from  Implementing DevOps with Microsoft Azure

Product typeBook
Published inApr 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781787127029
Edition1st Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Mitesh Soni
Mitesh Soni
author image
Mitesh Soni

Mitesh Soni has 8 years of experience in managing software for GNU/Linux and other UNIX-like operating systems in production environment. He started working as a professional with DevOps from 2013 and has worked on several live projects related to DevOps. https://www.linkedin.com/in/alessiogarofalo
Read more about Mitesh Soni

Right arrow

Chapter 5. Azure App Service Environments

Most people overestimate what they can do in one year and underestimate what they can do in ten years.                                                                                                                                –Bill Gates

This chapter is a bit theoretical, but it covers a premium service of Microsoft Azure platform that can be used for specific use cases that Azure Web Apps may not be able to handle effectively. Other than that, it is important to know why we are covering Azure Web Apps and App Service Environment (ASE). The reason behind that is it is equally important to have an environment ready for package deployment. When we consider it in the context of Java, we need to deploy the WAR file in a different environment. Here, we are dealing with PaaS so we need not worry about installing a runtime environment, else we will also need to find ways to automate it.

This chapter not only covers how to create ASEs but also provides...

Overview of ASEs


An ASE provides a dedicated and isolated environment to run Azure App Service. ASE is a premium service offered in Microsoft Azure. It provides more instances to scale if Azure Web Apps is hosted in an ASE. In Azure Web Apps, we have a Networking section where we can integrate Azure Web Apps with Azure VNet. In ASE, we can host Azure Web Apps in the VNet itself. In other words, ASE can be created in the subnet of a VNet as they are deployed in a VNet created by the account owner.

The benefit of hosting Azure App Service or Azure Web Apps in the ASE is that we can configure security for Azure Web Apps the way we do it for Azure VNet. In simple terms, we can use Network Security Groups (NSGs) to make it more secure. We can create NSGs with inbound and outbound rules to control traffic to Azure Web Apps. Thus, we can create a hybrid cloud scenario where Azure Web Apps can communicate with on-premise resources over a secure connection.

It also provides more instances in scaling...

Creating and configuring ASEs


Let's create an ASE with following:

  • Front end pool with two P2 compute resources
  • Worker pool 1 with two P1 compute resources
  • Worker pool 2 with zero P2 compute resources
  • Worker pool 3 with zero P3 compute resources
  • Single IP address to be used for IP SSL
  • VNet with 512 addresses using an RFC 1918 private address space; subnet with 256 addresses

To create an ASE follow, these steps:

  1. In the left sidebar, find App Service Environments.

Note

If it is not available, then click on More services and filter App Service Environments. Click on the star icon to bring that link on the left sidebar.

  1. Click on +Add. Enter Name for the ASEs, select Subscription, and select Resource Group (we already created the eTutorialsWorld resource group) by clicking on Use existing:
  1. Click on Virtual Network and on Create New. Enter name for the Virtual Network and select a Location. Click on OK:

Once we have configured VNet with the proper location, we can go back to the pane where other details of...

Enforcing HTTP redirection to HTTPS on Azure Web Apps


By default, Azure App Service does not enforce HTTPS. We can enforce HTTPS redirection by configuring the rules in the web.config file. 

In our normal Azure Web Apps URL, add scm after the name of the Azure web application. It opens a Kudu editor:

Go to Debug console and navigate to the wwwroot directory in the Kudu editor. 

Create web.config by executing the touch web.config command in the console:

Click on the Edit icon of the file and we can add the following content to redirect HTTP to HTTPS:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
      <!-- BEGIN rule TAG FOR HTTPS REDIRECT -->
        <rule name="Force HTTPS" enabled="true">
          <match url="(.*)" ignoreCase="false" />
          <conditions>
            <add input="{HTTPS}" pattern="off" />
          </conditions>
            <action type="Redirect...

Filtering traffic by IP and dynamic IP restrictions


We may want to restrict access to Azure Web Apps. We can achieve this using the <ipSecurity> element. We can define which IP addresses can access Azure, and the action to take in case of a violation of  that rule:

<configuration>
  <system.webServer>
    <security>
      <ipSecurity allowUnlisted="true" denyAction="NotFound">
        <add allowed="true" ipAddress="xxx.xxx.xxx.xxx"      
         subnetMask="255.xxx.xxx.xxx"/>
      </ipSecurity>
    </security>
  </system.webServer>
</configuration>

Dynamic IP restrictions allow us to block access to Azure Web Apps based on different scenarios as follows:

  • To deny access by maximum concurrent requests
  • To deny access by maximum requests within the specified time period

To configure dynamic IP restriction, make the following changes to the web.config file:

<configuration>
  <system.webServer>
    <security>
      <dynamicIpSecurity...

Comparing ASE and non-ASE (Azure Web Apps) 


The following are some but not all the differences between ASE and non-ASE:

Summary


Security is not a tool, a technology, or a one-time job, but an ongoing process. In this chapter, we discussed how to create ASE that is more secure than non-ASE or a normal Azure App Service. App Service is a PaaS offering from Microsoft Azure. ASEs offer App Service in the VNet and hence we can configure NSG to make the environment more secure. 

In other words, we can configure inbound and outbound security rules for traffic that flows inwards and outwards.

So far, we have covered continuous development using the Eclipse IDE and its integration with source code repository in VSTS. We also discussed how to perform continuous integration, how to create Azure Web Apps in a non-ASE environment, and how to manage Azure Web Apps as well. 

We need to understand that in ASE and non-ASE scenarios, only the hosting environment differs. Azure Web Apps related tasks and operations are same.

Our next goal is to deploy a package file in an environment that we have created that is Azure Web Apps...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Implementing DevOps with Microsoft Azure
Published in: Apr 2017Publisher: PacktISBN-13: 9781787127029
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Mitesh Soni

Mitesh Soni has 8 years of experience in managing software for GNU/Linux and other UNIX-like operating systems in production environment. He started working as a professional with DevOps from 2013 and has worked on several live projects related to DevOps. https://www.linkedin.com/in/alessiogarofalo
Read more about Mitesh Soni

non-ASE

ASE

Virtual Network

Azure Web Apps are hosted in a multitenant environment. We can configure Azure Web Apps to integrate it with VNet.

ASEs are created in the VNet, so Azure Web Apps are hosted in Azure VNet.

Resource layers

There are instances that can be utilized directly in ASP.

In ASE, we have two layers: 

Front end pool: This is used for load balancing and SSL termination

Worker pools: There are three worker pools in ASE. Instances available in the worker pools are used in the creation of ASP, and then we can host Azure Web Apps in the ASP.

Support for NSGs

Azure App Service / Azure Web Apps is a PaaS and not hosted in VNet. Hence, we can't configure inbound and outbound rules. 

As ASE is in VNet, we can configure the subnet with NSG. Hence, we can configure inbound security rules and outbound security rules.

Instance size(s)

Only three types of instance can be used in Azure...