In the previous recipe, you created and used the basic Azure management environment by downloading the key modules, logging in to Azure, and having a brief look around. In this recipe, you create certain key Azure assets, including a resource group, a storage account, and tags.
With Azure, all Azure resources are created within a resource group
. A resource group is a grouping of Azure resources. Any storage you create within Azure resides in a storage account, a fundamental building block within Azure.
All storage you use with any Azure feature always exists within a storage account. You create a storage account within one of the Azure regions you saw in the Using PowerShell with Azure recipe. When you create your storage account, you also specify the level of resiliency and durability that's provided. There are several levels of replication provided within Azure, which provide for multiple copies of the data that are replicated automatically in both the local Azure data center but also in other data centers. The extra resilience, which does come at a price, provides greater levels of recovery should the unthinkable happen and an entire data center somehow fails in a catastrophic way.
You can provision a storage account as either standard or premium. A standard storage account allows you to store any kind of data (as you see in the Exploring your storage account recipe). A premium storage account provides extra features, but at a cost.
Tags are name/value pairs that allow you to organize your resources within your subscription. For more details on how you can use tags to organize your Azure resources, see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-using-tags/.
This recipe requires you to have an Azure account and that you have your system configured with the Az
module, which was done in the Using PowerShell with Azure recipe.
$Locname = 'uksouth' # location name $RgName = 'packt_rg' # resource group we are using $SAName = 'packt42sa' # Storage account name
$CredAZ = Get-Credential Login-AzAccount -Credential $CredAZ
$RGTag = [Ordered] @{Publisher='Packt'} $RGTag += @{Author='Thomas Lee'} $RGHT = @{ Name = $RgName Location = $Locname Tag = $RGTag } $RG = New-AzResourceGroup @RGHT $RG
Resource Group
details:Get-AzResourceGroup -Name $RGName | Format-List -Property *
Storage Account
name is available:Get-AzStorageAccountNameAvailability $SAName
Storage Account
within our newly created resource group:$SAHT = @{ Name = $SAName SkuName = 'Standard_LRS' ResourceGroupName = $RgName Tag = $RGTag Location = $Locname } New-AzStorageAccount @SAHT
Storage Account
in this Resource Group
:$SA = Get-AzStorageAccount -ResourceGroupName $RgName $SA | Format-List -Property *
Storage Account
:$SA.PrimaryEndpoints
SKU
for this Storage Account
:$SA.Sku
C
property of your Storage Account
:$SA.Context
In step 1, you set the value of a number of key variables that are used in this recipe. In step 2, you logged in to your Azure account. Neither of these steps produce output.
In step 3, you created a new Azure Resource Group and gave it some nice tags. This step produces output like this:
In step 4, you got the Resource Group
and viewed its properties, as follows:
To create a Storage Account, you needed to check that the name was available, as shown in step 5:
In step 6, you created a new Storage Account
:
In step 7, you used the Get-AzStorageAccount
cmdlet to view details of the Storage Account
, which looks like this:
In step 8, you examined the key endpoints for your newly created Storage Account
, which looks like this:
In step 9, you viewed the SKU for your Storage Account
, like this:
In step 10, you viewed the details of the Storage Account's Context
property, which looks like this:
With step 1, you created some variables and gave them the appropriate values. When you go to replicate these recipes, you may find that some of the names that are used here are already in use by other Azure customers. To run this and other recipes in this chapter, you may need to adjust these values. For example, the Storage Account
name that was used in the previous edition of this book has been taken by someone so it cannot be used!
In step 2, you used Login-AzAccount
to log in to Azure. In earlier versions of the Azure cmdlets, this cmdlet was somewhat restricted and did not support Microsoft accounts (for example, accounts that end in @MSN.Com
). That shortcoming is eliminated in the Az cmdlets.
In step 6, you created a new Storage Account, but only after you determined the storage account name was valid. With Azure, the Storage Name (an important part of the URIs that PowerShell uses to connect to Azure) must be globally unique. Thus, no two Azure customers in the world can use the same storage account names. To ensure that your account is valid, in step 5, you used the cmdlet Get-AzStorageAccountNameAvailability
to test that the name was indeed allowed. If the name was not valid, you would have to choose another storage account name and amend the recipe accordingly.
Resource groups are a fundamental part of the Azure Resource Management API. For a good introduction to the Azure Resource Management API, see https://docs.microsoft.com/en-us/azure/storage/common/storage-introduction.
Storage in Azure is both complex and somewhat different to on-premise storage solutions. Take a look at https://docs.microsoft.com/en-us/azure/storage/common/storage-introduction for an introduction to Azure Storage.
3.145.63.136