Today we are going to create a Storage Account for any kind of use and inside this storage account we are going to create a blob for logs and a file share.
In the last post we created a resource group, where we will provision resources during this and the next posts.
Open the Azure Cloud Shell, then choose your subscription, if the cloud shell is already open, we will add the following variables, with the information:
Then we will execute the command “New-AZStorageAccount” to create the storage from the variables assigned above.
New-AzStorageAccount -ResourceGroupName $RGNAME -Name $STRGACCNAME -Type $TypeSTRG -Location $LOCATION
The storage was successfully created.
With the storage created, we are going to create a container to allocate the “Logs” of our environment, for that we are going to assign some variables as well.
$STORAGEACCOUNT = Get-AzStorageAccount -ResourceGroupName $RGNAME -Name $STRGACCNAME
$CONTAINERNAME = “logs”
$CTX = $storageAccount.Context
After assigning the variables, let’s run the following command “New-AzStorageContainer” to create the container.
New-AzStorageContainer -Name $containerName -Context $ctx -Permission blob
Your container was successfully created.
Last but not least let’s create a “File Share” with the following variables.
$STORAGEACCOUNT = Get-AzStorageAccount -ResourceGroupName “RG_GETPRACTICAL” -Name “strggetpractical01”
$storageKey = (Get-AzStorageAccountKey -ResourceGroupName $storageAccount.ResourceGroupName -Name $storageAccount.StorageAccountName | select -first 1).Value
$storageContext = New-AzStorageContext -StorageAccountName $storageAccount.StorageAccountName -StorageAccountKey $storageKey
New-AzureStorageShare -Name “getpracticalshare” -Context $storageContext
The File Share was created successfully, now let’s check the container and the file share that were created.
Container for Logs:
File Share for files:
That’s all for today guys, until the next post!