Getting Started with Azure App Service for Web Apps
Microsoft offers a highly flexible and easy to use web application service. With the myriad of languages, runtimes, and options available for web applications, managed services make application deployments and configuration exceptionally easy. There are many options that Azure Web Apps offer such as:
- Code or Docker Runtimes
- Options available such as .NET Core, ASP.NET, Java, Node, PHP, Python, and Ruby
- Docker Container Utilizing Linux or Windows
- Deployments to Different Regions
- Application Insights
Why would you choose Azure App Service for Web Apps over a traditional LAMP stack? With a standard Linux, Apache, MySQL, and PHP stack, all of the requisite operating systems and security management come with unmanaged servers.
In comparison, provisioning a web app from Azure is very simple and can be available within minutes. Since these are managed services, many security aspects are well administered. This does not mean that there’s no need to handle the application and access security aspects, but by using a web app, security is easier to manage.
Deploying an Azure Web App
For this example, we are going to deploy a simple PHP 7.3 application. Since we don’t need much for this article, we will use the Free F1 plan.
Say Goodbye to Traditional PC Lifecycle Management
Traditional IT tools, including Microsoft SCCM, Ghost Solution Suite, and KACE, often require considerable custom configurations by T3 technicians (an expensive and often elusive IT resource) to enable management of a hybrid onsite + remote workforce. In many cases, even with the best resources, organizations are finding that these on-premise tools simply cannot support remote endpoints consistently and reliably due to infrastructure limitations.
Application Insights are not available for the Free F1 plan, which, if you need more detailed statistics, you will need to pick a higher-level plan.
To create this simple web app, we will fill in the following.
- Runtime Stack:
- Operating System:
- SKU and size:
We will not use application insights or tag our instance, so once the essential details are entered, proceed to Review + Create and provision the web app.
Exploring Web App Configuration
After provisioning the web app, navigate to the web app to see all of the available options. Several useful features will make configuring and managing your web app that much easier.
The number one most useful section is the Configuration section. This section allows you to set exposed application settings via environmental variables. This means that your code can consume the environmental variables (or the Docker container), and configure itself appropriately. In this way, you can abstract the configuration from the code and make quick changes as needed.
Authentication / Authorization
A common challenge is how to handle authentication and authorization within applications. Conveniently Azure Web Apps offer an authentication and authorization layer in front of your application. As seen below, there are several available providers, such as Azure Active Directory, Microsoft, Facebook, Google, and Twitter.
Depending on the type of application that is being run, there are a number of built-in tools that are available to quickly manage and troubleshoot your application. The standard in-browser SSH session is available for Linux containers. Additionally the Advanced Tools that are available are Log Streams, Deployment Logs, and the ability to browse wwwroot via the browser.
Web SSH Session
So how do you get started deploying some code to our newly provisioned PHP 7.3 container? The recommended way to deploy code is by using GIT source control to push the code to the web app. If not already set up, you can navigate to Deployment → Deployment Center, and for this example, we will choose Local GIT.
Next, we will choose to use the Kudu App Service engine to build and deploy the code. Azure Pipelines is far more powerful and flexible, but we are going to keep the configuration simple for this article.
Before we can deploy code, we need to create Deployment Credentials. This is the account that GIT will use to connect and deploy the code. After you set up the source control for the application, you will be immediately dropped into the deployment center, and an option for Deployment Credentials should be visible. After clicking on that option, you will see the default App Credentials that are generated. Choose Show on the password to view the randomly generated password and use these credentials to connect GIT to this web app.
For our example, we have a single file in our repository that is
phpinfo.php and contains the line,
<?php phpinfo(); ?> which will show details of the PHP runtime environment. To deploy this file, we need to set up GIT for our web app. The first time that we deploy, the prompt to authenticate will be shown.
On a successful deployment, the git client will show the log output from the remote build process. This is very useful to know whether your application code has successfully deployed.
Additionally, if you navigate to the deployment center you will see the history of commits and the status of their deployments. Additionally, if you need to view the logs, you can do so with the associated link.
Navigating to your site and the
phpinfo.php location will show the resulting output from the
Azure App Service for Web Apps manages and deploys web apps of many different languages and runtimes quick and easy. With the ability to deploy any Docker container, you can quickly deploy a full WordPress container, for example, and control this instance via the Application Settings. Adding in MySQL for Web Apps means that you can tie a database storage engine to your applications and manage both together.
This flexibility frees up a web application and system administrators from the complexity and management of full Linux or Windows servers. With the extensive Azure ecosystem of services, Azure Services for Web Apps is just starting the capabilities that can be tied together and leveraged to create production-ready and scalable web application instances.