// Storage introduction: https://docs.microsoft.com/en-us/azure/storage/common/storage-introduction // Storage Explorer: https://azure.microsoft.com/en-us/features/storage-explorer/

// Install Azure PowerShell: https://docs.microsoft.com/en-us/powershell/azure/install-Az-ps?view=azps-5.6.0 // Install AZ-package

if ($PSVersionTable.PSEdition -eq 'Desktop' -and (Get-Module -Name AzureRM -ListAvailable)) { Write-Warning -Message ('Az module not installed. Having both the AzureRM and ' + 'Az modules installed at the same time is not supported.') } else { Install-Module -Name Az -AllowClobber -Scope AllUsers -Force }

Get-InstalledModule -Name "Az"

// Create a storage account: https://docs.microsoft.com/en-us/azure/storage/common/storage-account-create?tabs=azure-powershell // Create Storage Account

// Connect via dialog Connect-AzAccount

// - Get locations // - - See map: https://azure.microsoft.com/en-us/global-infrastructure/geographies/ Get-AzLocation | Select Location, DisplayName

// Create resource group $resourceGroup = "westeurope-resource-group-test" $location = "westeurope" New-AzResourceGroup -Name $resourceGroup -Location $location

// Create storeage // - See Storage Account Overview: https://docs.microsoft.com/en-us/azure/storage/common/storage-account-overview // - See Kind options: https://azurehangout.com/azure-storage-options/ $storageAccountName = "StorageStorage" New-AzStorageAccount -ResourceGroupName $resourceGroup -Name $storageAccountName -Location $location -SkuName Standard_RAGRS -Kind StorageV2 // - See Kind options: https://azurehangout.com/azure-storage-options/

// Get storage account $storageAccount = Get-AzStorageAccount -ResourceGroupName $resourceGroup -Name $storageAccountName

// Create Table: https://docs.microsoft.com/en-us/azure/storage/tables/table-storage-how-to-use-powershell $ctx = $storageAccount.Context $tableName = "ncttesttable" New-AzStorageTable –Name $tableName –Context $ctx $storageTable = Get-AzStorageTable –Name $tableName –Context $ctx

$cloudTable = $storageTable.CloudTable

// Add row Add-AzTableRow -table $cloudTable -partitionKey "Application" -rowKey ("FastPass","Test") -property @{"username"="Steven";"userid"=4}

// Get data: https://docs.microsoft.com/en-us/azure/storage/tables/table-storage-how-to-use-powershell $table = Get-AzTableTable -resourceGroup $resourceGroup -storageAccountName $storageAccountName -TableName "ncttesttable"

// Queue create: https://docs.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues $queueName = "todoqueue" $queue = New-AzStorageQueue -Name $queueName -Context $ctx

// Create queue message $queueMessage = [Microsoft.Azure.Storage.Queue.CloudQueueMessage]::new("This is message 1") $queue.CloudQueue.AddMessageAsync($QueueMessage)

// Get $invisibleTimeout = [System.TimeSpan]::FromSeconds(10) $queueMessage = $queue.CloudQueue.GetMessageAsync($invisibleTimeout,$null,$null) $queueMessage.Result

// Get and delete (within time space eg $invisibleTimeout) $queueMessage = $queue.CloudQueue.GetMessageAsync($invisibleTimeout,$null,$null) $queueMessage.Result $queue.CloudQueue.DeleteMessageAsync($queueMessage.Result.Id,$queueMessage.Result.popReceipt)

// REMOVE STORAGE ACCOUNT $resourceGroup = "westeurope-resource-group-test" $storageAccountName = "nctstoragestorage" Remove-AzStorageAccount -Name $storageAccountName -ResourceGroupName $resourceGroup

// TODO // Selecting Items from a List Box: https://docs.microsoft.com/en-us/powershell/scripting/samples/selecting-items-from-a-list-box?view=powershell-7.1

Get-InstalledModule Install-Module -Name AzTable -Force