Azure Administration using PowerShell & Portal
Login Azure Portal using PowerShell command-
PowerShell Command-
Connect-AzAccount
Once you enter this command login window will pop-up, enter your Azure account id and password, then it will ask for Enter Code which will be display to your mobile app- Microsoft Authentication, enter the code
Code valid till 30 Seconds only, you will get new code automatically .
After login you will be getting screen as below-
Logout of the Azure account you are connected with in your session PowerShell Command
Logout-AzAccount
List all subscriptions in all tenants the account can access
PowerShell Command
PowerShell Command
Get-AzSubscription
Azure PowerShell cmdlets follow a standard naming convention for PowerShell, VERB-NOUN. The verb describes the action (examples include New, Get, Set, Remove) and the noun describes the resource type (examples include AzVM, AzKeyVaultCertificate, AzFirewall, AzVirtualNetworkGateway). Nouns in Azure PowerShell always start with the prefix Az. For the full list of standard verbs
Get-Command -Verb Get -Noun AzVM* -Module Az.Compute
Azure Terminology
Resource - A manageable item that is available through Azure. Virtual machines, storage accounts, web apps, databases, and virtual networks are examples of resources.
Resource Group - A container that holds related resources for an Azure solution. The resource group includes those resources that you want to manage as a group. You decide which resources belong in a resource group based on what makes the most sense for your organization.
Azure Resource Manager- is the deployment and management service for Azure. It provides a management layer that enables you to create, update, and delete resources in your Azure subscription. You use management features, like access control, locks, and tags, to secure and organize your resources after deployment.
Below image represents the role Azure Resource Manager plays in handling Azure requests.
Azure Resource Manager- is the deployment and management service for Azure. It provides a management layer that enables you to create, update, and delete resources in your Azure subscription. You use management features, like access control, locks, and tags, to secure and organize your resources after deployment.
Consistent management layer
When a user sends a request from any of the Azure tools, APIs, or SDKs, Resource Manager receives the request. It authenticates and authorizes the request. Resource Manager sends the request to the Azure service, which takes the requested action. Because all requests are handled through the same API, you see consistent results and capabilities in all the different tools.Below image represents the role Azure Resource Manager plays in handling Azure requests.
All capabilities that are available in the portal are also available through PowerShell, Azure CLI, REST APIs, and client SDKs. Functionality initially released through APIs will be represented in the portal within 180 days of initial release.
How to Create a Resource Group using Azure Portal-
- Search for Resource Group in search bar.
- Click on Create Resource Group
- Select the Subscription
- Enter Resource Group Name- e.g. "RG1"
- Select the Region where you wanted to publish your resource- "Central-US". .
- Review & Create as shown in image.
Create a Resource Group using PowerShell command -
New-AzResourceGroup -Name 'RG2' -Location 'eastus'
Get resource groups PowerShell Commands
Get-AzResourceGroup
Get-AzResourceGroup
LAB Exercise for you
Get a specific resource group by name
Get-AzResourceGroup -Name "RG2"
Get resource groups where the name begins with “RG”
Get-AzResourceGroup | Where ResourceGroupName -like RG*
Get resource groups where the name begins with “RG”
Get-AzResourceGroup | Where ResourceGroupName -like RG*
Find resources of a type in resource groups with a specific name
Get-AzResource -ResourceGroupName "RG2"
Show resource groups by location
Get-AzResourceGroup |
Sort Location,ResourceGroupName |
Format-Table -GroupBy Location
Show resource groups by tag
Get-AzResourceGroup |
Sort Location,ResourceGroupName |
Format-Table -GroupBy Tags
Delete a Resource Group
Remove-AzResourceGroup -Name "RG2"
Move the Resource to the New Group
Move-AzResource -ResourceId $Resource.ResourceId -DestinationResourceGroupName
"RG1"
Get-AzResource -ResourceGroupName "RG2"
Show resource groups by location
Get-AzResourceGroup |
Sort Location,ResourceGroupName |
Format-Table -GroupBy Location
Show resource groups by tag
Get-AzResourceGroup |
Sort Location,ResourceGroupName |
Format-Table -GroupBy Tags
Delete a Resource Group
Remove-AzResourceGroup -Name "RG2"
Move the Resource to the New Group
Move-AzResource -ResourceId $Resource.ResourceId -DestinationResourceGroupName
"RG1"
You can protect your Resource Group for agains accidental steps as below.
We are learning here based on real scenario, hence most of the commands we will be learn based of topic with real examples.
No comments:
Post a Comment