Overview Of Azure CloudShell And Log Monitoring

In this article, we will explore how to use cloud shell in Azure cloud platform with example of creation of Web app and monitor logs using cloud shell (PowerShell).

Introduction

In this article, we will explore how to use cloud shell in Azure Cloud platform with an example of the creation of the Web app and monitor logs using CloudShell (PowerShell).

Scenario

Azure Cloud has several ways to create and manage resources. CloudShell is one of the ways to create and manage the resources within your Azure cloud environment. Many times, we need to provide PowerShell script to the deployment/development team instead of creating and managing resources by using the portal. We can execute the sequence of instructions using PowerShell in one go.

Prerequisites

  1. Azure Cloud subscription
  2. Basic knowledge of PowerShell

Cloud Shell

  • CloudShell is a feature in the Azure cloud which gives us the facility to write in commands with browser-based experience.
  • CloudShell helps Azure technical team to manage and control the Azure resources.
  • We have a choice – Bash, PowerShell
  • Securely access to authenticate account access for PowerShell and CLI
  • CloudShell is integrated to open source objects as well
  • CloudShell supports to multiple languages – .NET Core, Go, Java, Nods.JS, PowerShell and Python

When to use Bash or PowerShell?

  • Generally, Bash is used to play around with Linux, etc. However, PowerShell is preferred to use with Windows (Microsoft’s ecosystem).
  • Using PowerShell, we can write this as a scripting language which deals with object-oriented commands.
  • PowerShell can be used with different technologies.

Now, we will focus on actual steps using cloud shell to create Web App in the Azure Cloud.

Step 1

Log into the Azure Portal.

Step 2

Click the on CloudShell icon. This icon is present on top of the horizontal bar in the Azure portal site.

Overview Of Azure Cloud Shell And Log Monitoring 

Step 3

The system prompts you to select type – Bash or PowerShell. In the current article, I am selecting PowerShell.

Overview Of Azure Cloud Shell And Log Monitoring 

Note
If you are using the CloudShell for the first time, then you need to create a new storage account because CloudShell requires Azure file share.

Step 4

Click on ‘Create Storage’ or click on ‘advanced setting’ to select the proper CloudShell region, resource group, storage account name, file share name details.

Overview Of Azure Cloud Shell And Log Monitoring 

Now, the system will authenticate to Azure and open default drive ‘Azure’.

Overview Of Azure Cloud Shell And Log Monitoring 

Step 5

To create web app in Azure – first, we need to create a resource group and service plan.

Overview Of Azure Cloud Shell And Log Monitoring
Create variables and assign values

$rg=" pshellrg "
$app="pshellwebapptest"
$location="Southeast Asia"
$serviceplan="psserviceplan"

Create Resource Group
New-AzureRMResourceGroup -Name $rg -Location $location

When the command runs successfully then the system shows the below message,

Overview Of Azure Cloud Shell And Log Monitoring 

We can also verify resource group in the portal.

Overview Of Azure Cloud Shell And Log Monitoring 
 
Create a Service Plan
New-AzureRMAppservicePlan -Name $serviceplan -Tier Basic -ResourceGroupName $rg -Location $location

When the command runs successfully, the system shows the below message.

Overview Of Azure Cloud Shell And Log Monitoring 
 
Create a Web app under the above-created resource group and link to a service plan.
New-AzureRMWebApp -Name $app -ResourceGroupName $rg -Location $location -AppServicePlan $serviceplan

When the command runs successfully, then the system shows the below message.

Overview Of Azure Cloud Shell And Log Monitoring 

We can also verify the web app in the portal.

Overview Of Azure Cloud Shell And Log Monitoring 
 
Enable web server logs to the web app.
 
Set-AzureRMWebApp -RequestTracingEnabled $True -HttpLoggingEnabled $True -DetailedErrorLoggingEnabled $True -ResourceGroupName $rg -Name $app

When the command runs successfully, then the system shows the below message.

Overview Of Azure Cloud Shell And Log Monitoring