An Azure service that provides cloud messaging as a service and hybrid integration.
Hi @rain purple ,
It sounds like you’ve successfully generated a .NET console app in Cloud Shell but you’re hitting C# compile errors (CS1002, CS1026, CS1529) right after pasting in the sample code. Those error codes usually pop up when the compiler finds unexpected characters (like “smart quotes”, stray markdown symbols or missing semicolons) or when the code uses C# features not supported by your SDK version.
Here's a checklist to help you zero in on the issue:
- Verify your .NET SDK version
- Run
dotnet --versionin Cloud Shell. - The sample code uses top-level statements and async Main which require .NET 6 or later.
- If you’re on an older SDK, recreate the console app with:
or update your Cloud Shell to use a newer SDK.dotnet new console --framework net6.0 --name ServiceBusQuickStart
- Run
- Clean up any invalid characters
- Open
Program.csin your editor (e.g.code Program.csorvi Program.cs). - Replace any curly quotes (“ ”) with straight quotes (") and remove any bullet numbers or markdown prefixes that snuck in.
- Make sure each statement ends with a semicolon where required.
- Open
- Grab the raw sample code directly from the repo
- Go to the GitHub instructions page: https://github.com/MicrosoftLearning/mslearn-azure-developer/blob/main/instructions/azure-events-messages/03-service-bus-send-receive.md
- Click “Raw” to view the unformatted code block and copy-paste that straight into your
Program.cs.
- Build and run
If everything is formatted correctly and you have the package installed (dotnet build dotnet rundotnet add package Azure.Messaging.ServiceBus), it should compile and send/receive messages.
Alternative ways to send a Service Bus message without writing a full C# app:
- Azure CLI (with the Service Bus extension):
az servicebus queue send \ --resource-group MyRG \ --namespace-name MyNamespace \ --queue-name MyQueue \ --body "Hello from Cloud Shell!" - REST API via
curlor PowerShell’sInvoke-WebRequest. - Azure Portal’s built-in Service Bus Explorer blade (under your Service Bus namespace).
Inspecting files in Cloud Shell’s storage from the Azure portal:
- In the Azure portal, locate the “Storage account” named
cs<yourID>store(in the resource group ShellResources). - Click on “File shares” →
clouddrive→ Browse to see yourProgram.cs. - You can also mount that file share locally via Storage Explorer or AzCopy.
Unfortunately, you can’t export a C# source file as an ARM template (ARM templates export Azure resources, not code files). If you want persistent backups, just git-init your folder and push to GitHub or clone it to your local machine.
References:
- Azure Cloud Shell FAQ / Troubleshooting
- Troubleshooting Microsoft Learn training issues (including Cloud Shell hiccups)
Hope this helps!
If the resolution was helpful, kindly take a moment to click on and click on Yes for was this answer helpful. And, if you have any further query do let us know.