Azure provides number of PaaS services to deploy applications easily without worrying about the underlying infrastructure. Some of them include Azure Cloud Services, Azure Web Apps, Azure Mobile Apps, SQL Azure, Document DB, etc. The benefit of PaaS is developers can dedicate their time into developing the application without hassles of managing the infrastructure to deploy it.
Azure Web App
Azure Web App is one such service which allows developers to quickly build, manage, and deploy dynamic websites very easily. Azure Web App is a part of Azure App Service which is a PaaS offering from Azure to create Web and Mobile apps for any platform or device. Azure App Service includes various services like Web Apps, Mobile Apps, Logic Apps and API Apps. C#, HTML5, PHP, Python, Java, Node.js are some of the supported languages in Azure Web Apps.
Web App can be deployed in three ways:
- Through Azure ARM Portal
- Using Azure CLI
- Using Visual Studio
To deploy a simple Web App in Azure, we shall first create a Resource Group and an App Service plan. App Service plan define a collection of physical resources utilized to host your application such as Region, Instance size, the number of instances, and SKUs. Application Insights is Performance Management service for web developers which can be used with Web Apps.
SDKs and Other tools
To provision a Web App from Azure Portal, the only thing required is ACTIVE Azure Subscription. Provisioning a Web App from Azure portal will provision a simple container where you can deploy your files without having to manage the underlying infrastructure. After provisioning a Web App, required files can be added, modified or deleted in the number of ways stated below:
- Using Kudu which is web-based management tool and can be accessed from Azure Portal
- Using Azure CLI or Azure CLI 2.0 which will require local Git repositories
- Visual Studio 2012 or higher along with proper version of Azure SDK
Any FTP clients like WinSCP, for instance, can be used for FTP deployments
Here we shall see how can one deploy our files in Web App using FTP and using Visual Studio 2015.
provisioning a Web Apps from Azure Portal
To get started with Web Apps from Azure portal, navigate to portal.azure.com and enter your credentials to log in. Click on + New > Web + Mobile and select Web App.
Creating Web App
Enter appropriate name for the web app. This will also be the part of the URL to browse your web app. Select the Azure Subscription. Under Resource Group, click Create New and enter Resource Group Name.
Creating App Service Plan
Under App Service Plan, click on Create New. Enter App Service Plan name, select Location and in Pricing Tier select Basic B1.
Turn On the Application Insights and click Create.
Once the Web App is deployed, we can browse to see the following page.
Deploying custom files to Web App
To deploy custom files to Azure Web App, navigate to your web app blade and take note of the FTP credentials. We shall use WinSCP to upload custom files to Web App. For example, here we will create a simple `index.html` file. Use any text editor to create this file and save it as `index.html`. The content of the file should be as shown below:
<title>Sample "Azure Web App" Application</title>
<p>This is the <i>home page</i> for the new <b>Azure Web App</b> deployed through Azure Portal. </p>
Now, on Web App settings blade, click on Deployment credentials and set password for FTP and SFTP.
Go back to Overview tab, copy FTP hostname and paste it in WinSCP. Do the same for FTP/deployment username, and enter the password in WinSCP to connect to web app.
Once the connection is established, go to site > wwwroot folder on the right pane. On left pane, navigate to index.html file we created previously. Right-click and upload that file inside wwwroot folder.
Browse to web app again and we can see new file in homepage of the webapp.
Deploy Web App using Visual Studio
Creating Web App in Visual Studio 2015
To create a simple web application in Visual Studio, click on File > New Project. Under Visual C#, select Web and on right hand pane select ASP.NET Web Application.
On the next page, select Single Page Application and make sure Host in Cloud option is checked.
On the next page, enter the web app name that is suitable for a URL. Select the Subscription, Resource Group and App Service Plan. We will use the previously created properties. Once done, click Create.
Deploying Web App in Azure
Once the solution is ready, click on Publish site option in Web Publish Activity.
On Publish dialog box, verify the values and click Publish button to publish web app on Azure.
Once published, the URL of the website will be available in Output Window.
Thus, the new Web App is ready to roll in few easy steps.
Sources / Resources
Azure also supports deploying various CMS and e-commerce applications like WordPress, Joomla, Drupal, Magento, etc. to deploy on Azure Web Apps. These are available in Azure Marketplace. Go ahead and explore more!
Click here for more courses on Azure from Linux Academy.