In this lab, you will gain experience using C#, the Azure Cloud Shell/PowerShell/CLI, and Visual Studio to connect to and use Azure Service Bus queues.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Set Up Cloud Shell and Use PS/CLI to Create a Service Bus Namespace and Queue
- Run PowerShell as administrator and create the needed Azure resources.
# create a Service Bus namespace and queue $resourceGroup = az group list --query '[0].name' --output json $namespaceName = "LALab" + (Get-Date).ticks
az servicebus namespace create –resource-group $resourceGroup –name $namespaceName –location [Enter your lab’s Resource Group location here]
az servicebus queue create –resource-group $resourceGroup –namespace-name $namespaceName –name myQueue
#- Run PowerShell as administrator and create the needed Azure resources.
- Download the C# Code and Launch the VS Solution
RDP login:
UserName : "azureuser" Password : "LA!2018!Lab"
PowerShell to run:
$url = "https://github.com/ACloudGuru-Resources/content-azure-labs/blob/master/zips/azure-service-bus-queues.zip?raw=true" $zipfile = "C:UsersazureuserDesktopazure-service-bus-queues.zip" $folder = "C:UsersazureuserDesktop" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Invoke-WebRequest -UseBasicParsing -OutFile $zipfile $url Expand-Archive -LiteralPath $zipfile -DestinationPath $folder Remove-Item -Path $zipfile
- Update Visual Studio Solution and Run the Console App
Modify the partially completed C# code that was provided to allow interaction with the Service Bus queues.
Begin the process of sending messages.
Observe the message count in the Azure Service Bus Queue is showing ten messages.
Return to your VM and press any key to receive the messages.
Observe the message count in the Azure Service Bus queue is showing zero messages.