Author : MD TAREQ HASSAN | Updated : 2020/11/18
What is App service Web app?
- Web Apps is a fully managed platform that enables you to build, deploy, and scale enterprise-grade Web Apps
- A cloud computing based platform for hosting websites
- A platform as a service which allows publishing Web apps running on multiple frameworks and written in different programming languages
- Web Apps provides a platform to build an App in Azure without having to deploy, configure and maintain your own Azure VM’s
Web Apps vs API apps
- Both uses same compute service (Azure App Service)
- All features available for one is available to the other
- No differences under the hood. Only different icons, name and an API Definition that is populated in case of API app
Why to use
- Continuous deployment with Git, Team Foundation Server, GitHub, and DevOps
- Built-in autoscale and load balancing
- Supports WordPress, Umbraco, Joomla!, and Drupal
- High availability with auto-patching
- Supports Windows and Linux platforms
Prerequisites of creating WebApp
Create Resource Group:
- Go to: https://portal.azure.com/#create/Microsoft.ResourceGroup (login to Azure portal first, then click the link)
- Fillup details (i.e. name ‘
demo-rg
’, select subscription etc.) - Create
App service plan and Application Insights:
Creating WebApp using Azure portal
- Go to: https://portal.azure.com/#create/Microsoft.WebSite
- Fillup details > Create and review
- Create
Creating Web App using PowerShell
New-AzWebApp -ResourceGroupName "demo-rg" -AppServicePlan "demo-asp" -Name "dem0webapp" -Location "Japan East"
Add Application Insights
- Using Azure portal
- Go to App service WebApp
- Settings > Application Insigjhts > Trun on Application Insights
- Select existing resource > Select Application Insights that created before
- Apply
- Using Azure PowerShell:
$app = Get-AzWebApp -ResourceGroupName "AppMonitoredRG" -Name "AppMonitoredSite" -ErrorAction Stop $newAppSettings = @{} # case-insensitive hash map $app.SiteConfig.AppSettings | %{$newAppSettings[$_.Name] = $_.Value} # preserve non Application Insights application settings. $newAppSettings["APPINSIGHTS_INSTRUMENTATIONKEY"] = "012345678-abcd-ef01-2345-6789abcd"; # set the Application Insights instrumentation key $newAppSettings["APPLICATIONINSIGHTS_CONNECTION_STRING"] = "InstrumentationKey=012345678-abcd-ef01-2345-6789abcd"; # set the Application Insights connection string $newAppSettings["ApplicationInsightsAgent_EXTENSION_VERSION"] = "~2"; # enable the ApplicationInsightsAgent $app = Set-AzWebApp -AppSettings $newAppSettings -ResourceGroupName $app.ResourceGroup -Name $app.Name -ErrorAction Stop
Links:
- Module: https://docs.microsoft.com/en-us/powershell/module/az.websites/
- Commands: https://docs.microsoft.com/en-us/powershell/module/az.websites/new-azwebapp
- Enable application insights through powershell
Creating Web App project in Visual studio
- Ctrl + Shift + N
- ASP.NET Core Web Application > Next
- Set project name > Create
- Web Application (Model-View-Controller) (change authentiction if needed)
- Create
Publishing Web App Project From Visual Studio
Add Azure account to Visual Studio:
- Visual Studio > Account settings
- Add account
- Use Azure credentials to login
- Now projects can be published to Azure from Visual Studio
Publishing from Visual Studio
- Right click on the project > Publish
- Azure > Next
- Azure App Service (Windows) > Next
- Select Subscription, Resource Group and App service > Finish
- Publish