logo
eng-flag

Microsoft Azure Cheatsheet

Table of Contents

  1. Introduction to Azure
  2. Core Azure Services
  3. Azure Portal
  4. Azure CLI
  5. Azure PowerShell
  6. Virtual Machines
  7. Azure Storage
  8. Azure Active Directory
  9. Azure SQL Database
  10. Azure Functions
  11. Azure Resource Manager (ARM) Templates
  12. Virtual Network
  13. Azure Monitor
  14. Best Practices and Security

Introduction to Azure

Microsoft Azure is a cloud computing platform that offers a wide range of services including computing, analytics, storage, and networking. Users can pick and choose from these services to develop and scale new applications or run existing applications in the public cloud.

Key Benefits:

  • Flexibility
  • Cost-effectiveness
  • Scalability
  • Global reach
  • Integrated development environment

Core Azure Services

  1. Compute: Virtual Machines, App Service, Azure Functions
  2. Storage: Blob Storage, File Storage, Queue Storage, Table Storage
  3. Database: Azure SQL Database, Cosmos DB, Azure Database for MySQL
  4. Networking: Virtual Network, Load Balancer, VPN Gateway
  5. Security: Azure Active Directory, Key Vault
  6. Management: Azure Monitor, Azure Resource Manager

Azure Portal

The Azure Portal is a web-based, unified console that provides an alternative to command-line tools.

  1. Accessing the Portal:

    • Go to portal.azure.com
    • Sign in with your Microsoft account
  2. Portal Organization:

    • Dashboard
    • All services menu
    • Favorites bar
    • Search bar
  3. Creating a New Resource:

    • Click "Create a resource"
    • Select the resource type
    • Follow the creation wizard

Azure CLI

The Azure CLI is a command-line tool for managing Azure resources.

  1. Installation:

    curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
    
  2. Login:

    az login
    
  3. Basic Command Structure:

    az <command-group> <command> <options>
    
  4. Example Commands:

    az group list
    az vm create --resource-group myResourceGroup --name myVM --image UbuntuLTS --generate-ssh-keys
    az storage account list
    

Azure PowerShell

Azure PowerShell is a set of cmdlets for managing Azure resources directly from the PowerShell command line.

  1. Installation:

    Install-Module -Name Az -AllowClobber -Scope CurrentUser
    
  2. Login:

    Connect-AzAccount
    
  3. Example Commands:

    Get-AzResourceGroup
    New-AzVM -ResourceGroupName "myResourceGroup" -Name "myVM" -Location "EastUS" -VirtualNetworkName "myVNet" -SubnetName "mySubnet" -SecurityGroupName "myNSG" -PublicIpAddressName "myPublicIp"
    Get-AzStorageAccount
    

Virtual Machines

Azure Virtual Machines (VMs) are one of several types of on-demand, scalable computing resources that Azure offers.

  1. Create a VM:

    az vm create      --resource-group myResourceGroup      --name myVM      --image UbuntuLTS      --admin-username azureuser      --generate-ssh-keys
    
  2. Connect to a VM:

    ssh azureuser@<public-ip-address>
    
  3. Stop a VM:

    az vm stop --resource-group myResourceGroup --name myVM
    
  4. Start a VM:

    az vm start --resource-group myResourceGroup --name myVM
    
  5. Delete a VM:

    az vm delete --resource-group myResourceGroup --name myVM
    

Azure Storage

Azure Storage is Microsoft's cloud storage solution for modern data storage scenarios.

  1. Create a Storage Account:

    az storage account create      --name mystorageaccount      --resource-group myResourceGroup      --location eastus      --sku Standard_LRS
    
  2. Create a Container:

    az storage container create      --name mycontainer      --account-name mystorageaccount
    
  3. Upload a Blob:

    az storage blob upload      --account-name mystorageaccount      --container-name mycontainer      --name myblob      --file ~/path/to/local/file
    
  4. List Blobs:

    az storage blob list      --account-name mystorageaccount      --container-name mycontainer      --output table
    

Azure Active Directory

Azure Active Directory (Azure AD) is Microsoft's cloud-based identity and access management service.

  1. Create a New User:

    az ad user create      --display-name "John Doe"      --password "Password123!"      --user-principal-name john.doe@contoso.com
    
  2. List Users:

    az ad user list --output table
    
  3. Create a Group:

    az ad group create      --display-name "Marketing Group"      --mail-nickname "marketing"
    
  4. Add User to Group:

    az ad group member add      --group "Marketing Group"      --member-id <user-object-id>
    

Azure SQL Database

Azure SQL Database is a fully managed platform as a service (PaaS) database engine.

  1. Create a SQL Server:

    az sql server create      --name myserver      --resource-group myResourceGroup      --location eastus      --admin-user myadmin      --admin-password Password123!
    
  2. Create a Database:

    az sql db create      --resource-group myResourceGroup      --server myserver      --name mydb      --service-objective S0
    
  3. List Databases:

    az sql db list      --resource-group myResourceGroup      --server myserver
    
  4. Delete a Database:

    az sql db delete      --resource-group myResourceGroup      --server myserver      --name mydb
    

Azure Functions

Azure Functions is a serverless compute service that enables you to run code on-demand without having to explicitly provision or manage infrastructure.

  1. Create a Function App:

    az functionapp create      --resource-group myResourceGroup      --consumption-plan-location eastus      --runtime dotnet      --functions-version 3      --name myfunctionapp      --storage-account mystorageaccount
    
  2. Deploy a Function:

    az functionapp deployment source config-zip      --resource-group myResourceGroup      --name myfunctionapp      --src path/to/function.zip
    
  3. List Functions:

    az functionapp function list      --resource-group myResourceGroup      --name myfunctionapp
    
  4. Delete a Function App:

    az functionapp delete      --resource-group myResourceGroup      --name myfunctionapp
    

Azure Resource Manager (ARM) Templates

ARM templates allow you to define and deploy Azure infrastructure declaratively.

  1. Deploy an ARM Template:

    az deployment group create      --resource-group myResourceGroup      --template-file template.json      --parameters parameters.json
    
  2. Export a Template:

    az group export      --name myResourceGroup      > template.json
    
  3. Validate a Template:

    az deployment group validate      --resource-group myResourceGroup      --template-file template.json
    

Virtual Network

Azure Virtual Network (VNet) is the fundamental building block for your private network in Azure.

  1. Create a VNet:

    az network vnet create      --resource-group myResourceGroup      --name myVNet      --address-prefix 10.0.0.0/16      --subnet-name mySubnet      --subnet-prefix 10.0.1.0/24
    
  2. Create a Network Security Group:

    az network nsg create      --resource-group myResourceGroup      --name myNSG
    
  3. Add a Security Rule:

    az network nsg rule create      --resource-group myResourceGroup      --nsg-name myNSG      --name myNSGRule      --protocol tcp      --direction inbound      --source-address-prefix '*'      --source-port-range '*'      --destination-address-prefix '*'      --destination-port-range 80      --access allow      --priority 200
    

Azure Monitor

Azure Monitor provides full stack monitoring, smart analytics, and intelligence over your applications and infrastructure.

  1. Create a Log Analytics Workspace:

    az monitor log-analytics workspace create      --resource-group myResourceGroup      --workspace-name myWorkspace
    
  2. Enable VM Insights:

    az vm insight enable      --resource-group myResourceGroup      --vm myVM
    
  3. Create an Alert Rule:

    az monitor metrics alert create      --resource-group myResourceGroup      --name myAlert      --scopes /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM      --condition "avg Percentage CPU > 90"      --window-size 5m      --evaluation-frequency 1m
    

Best Practices and Security

  1. Use Azure Policy to enforce organizational standards
  2. Implement Multi-Factor Authentication (MFA) for Azure AD users
  3. Use Role-Based Access Control (RBAC) to grant minimum necessary permissions
  4. Enable Azure Security Center for security recommendations and threat protection
  5. Use Azure Key Vault to store and manage sensitive information
  6. Regularly review and optimize your Azure costs
  7. Enable Azure Backup for your critical resources
  8. Use Azure Update Management to keep your VMs patched and secure
  9. Implement network security groups and application security groups to control traffic flow
  10. Use Azure Monitor and Log Analytics for comprehensive monitoring and alerting

2024 © All rights reserved - buraxta.com