learning.appsecengineer.com-Course Lab
learning.appsecengineer.com-Course Lab
learning.appsecengineer.com/portal/course-
info/lab/ZXZlbnRfOWQyNGU3NDEtZjRiZS00YWJjLTlkZmEtNGY3NTFjNTliMDdi/c3ViamVjdF8zZTU3N2JhNC03YzQ0LTRhNDYtODkxZC0wYmFkMmUzYzU1NGU=/bGFiXzk4OG
NjMDg0LWU0ZTQtNDViYS1hYjc3LTI3NzdhNjY2MmI1YQ==
23%
1/6
0:29:04
Overview
Instructions
Azure Sentinel
Important Information
For this lab, you will be accessing your Azure Account through our Lab Environment. This will need you to configure Azure CLI on
the Lab environment. We have taken several precautions to make this experience more secure. We have added:
TLS 1.2 to access each lab environment to ensure that your credentials are always encrypted in transit
An optional, Authenticated mode that adds an additional access control through HTTP Basic Authentication and a randomly
generated password, to ensure that the lab can be accessed only with the appropriate credentials. To ensure maximum security
of your Azure, please do the following:
DO NOT use your company's Azure Account. We recommend getting a throwaway Azure account for learning
Generate your Azure username and Password before using this lab and deactivate it immediately after you are done with the
lab
Ensure that you follow "Teardown" instructions in this lab and watch the Teardown videos to not incur unnecessary charges on
your account
Ensure that you use the "Authenticated" mode in our Lab environment. This adds an additional layer of access control to the
lab environment If you are not comfortable with any of the above, you can commence the lab, download the code for the lab
and use it on a machine of your choice. You will be responsible for downloading the necessary dependencies to get it to work/
Please note. We're NOT responsible for any charges or overages you incur on your Azure Account.
Introduction
Hi AppSecEngineer,
Azure Sentinel is a cloud-native security information and event management (SIEM) solution that provides intelligent security
analytics and threat intelligence across the enterprise. It helps detect, prevent, and respond to threats in real time using AI and
machine learning. With Azure Sentinel, you can collect data at cloud scale across all users, devices, applications, and infrastructure,
both on-premises and in multiple clouds. It simplifies security operations by providing a single solution for alert detection, threat
visibility, proactive hunting, and threat response.
Log Analytics is a cloud-based log management solution that provides a unified platform for log collection, storage, and analytics. It is
a cloud-based solution that provides a unified platform for log collection, storage, and analytics.
In this lab we will setup Log Analytics Workspace and explore its capabilities.
Azure Setup
Once you provision the server Click on Access button.
In the appeared window click on Terminal and select New terminal option.
Let's create a sandboxed Azure environment and configure the credentials file.(environmental)
Go to azure-creds.txt file.
2/6
Click on Azure Portal Login Link, enter azure_useremail and azure_password then click on sign in
az login --use-device-code
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code <random-value> to
authenticate.
Now access this url https://microsoft.com/devicelogin then select the recently logged in account and validate with the above
<random-value>
The default is marked with an *; the default tenant is 'we45.com' and subscription is 'ASE' (9bd6ba94-b6bb-4db6-bb2d-
195c89122943).
Implementation
We have two options to deploy the infrastructure.
Writing your own terraform code from scratch by following the instructions mentioned in the lab D.I.Y. Approach
Using our pre-written terraform code placed in the path /root/azure-sentinel/log-workspace Pre-written Approach.
If you would like to use our pre-written terraform code, skip the DO IT YOURSELF(D.I.Y.)Approach section and move Pre-written
Approach
Change Directory
cd /root/azure-sentinel/Developer
We have created an empty file with the name main.tf` under the Developer Directory. You will write the terraform code in this
file and save it. Finally, you will deploy the infrastructure by following the below steps.
Let's go through each block of code and understand what it does and how it works. Then we will leverage the same code to create
our own terraform code and deploy the infrastructure.
Provider Configuration
provider "azurerm" {
subscription_id = var.subscription_id
features {}
}
This Terraform configuration sets up the AzureRM provider version 3.43 from HashiCorp, allowing Terraform to manage resources in
Microsoft Azure. The provider block with features {} initializes Azure-specific settings with default values. The
required_providers section ensures the correct provider version is used for compatibility with Azure services.It uses the default
3/6
configuration, assuming you've already authenticated with Azure CLI.
Variables
variable "location" {
default = "West US"
}
variable "resourcegroupname" {
default = "my-ase-default-rg"
}
variable "subscription_id" {
type = string
description = "The Azure subscription ID"
}
This Terraform configuration defines three variables. The location sets a default region where resources will be created, in this case,
"West US". The resourcegroupname defines the default name for the resource group. The subscription_id is a placeholder for the
Azure subscription ID, which you'll need to provide. These variables make it easier to manage resources in Azure by allowing
changes without modifying the entire code.
Random String
This resource block generates a random string of 8 characters with lowercase letters. It's useful for creating unique names for
resources like storage accounts, virtual machines, or other Azure services. The random string is stored in the random resource and
can be referenced in other resource blocks.
This resource creates an Azure Log Analytics workspace. It's a centralized platform for collecting and analyzing logs from various
Azure resources. The workspace uses the "PerGB2018" pricing model and retains data for 30 days.
Outputs
output "log_workspace_name" {
value = azurerm_log_analytics_workspace.ase-log-workspace.name
}
This output block defines an output variable log_workspace_name that returns the name of the Log Analytics workspace created in
the resource block. It allows you to access the workspace name after deployment for further configuration or integration with other
resources.
Please copy the above code blocks in each instruction and paste it into the main.tf` file and save it.
If you have followed the above instructions, you have created your own terraform code. Now you can skip the Using our pre-written
terraform code section and move to the next section Deploying the infrastructure
Change Directory
cd /root/azure-sentinel/log-workspace
4/6
After writing the terraform code or using the pre-written code, you can now deploy the infrastructure.
Terraform is a tool designed for building, changing, and versioning infrastructure safely and efficiently. It supports both popular
service providers and custom in-house solutions.
terraform init
3. Set the Resource Group Name: Export the resource group name to variables.
The above command will create the infrastructure. It will take some time to complete.
Teardown
If you have followed the DO IT YOURSELF(D.I.Y.)Approach section, please change the directory to /root/azure-
sentinel/Developer
cd /root/azure-sentinel/Developer
If you have followed the Pre-written Approach section, please change the directory to /root/azure-sentinel/log-
workspace
Change Directory
cd /root/azure-sentinel/log-workspace
Note: Make sure you are in the correct directory before executing the following commands.
Ensure you're using the same terminal where the values for subscription_id and resourcegroupname have been set. If not,
please set their values by referring to the Deploying the Infrastructure section.
This will delete all the resources which we have created using terraform
5/6
References:
Azure Terraform Provider
Azure Log Analytics
Course Content
close
6/6