About This Page
This page is part of the Azure documentation. It contains code examples and configuration instructions for working with Azure services.
Bias Analysis
Bias Types:
⚠️
windows_first
⚠️
missing_linux_example
⚠️
windows_tools
⚠️
powershell_heavy
Summary:
The documentation page demonstrates a strong Windows bias throughout. All code samples and application instructions are based on C#/.NET and target Windows platforms (e.g., Windows Store app, Windows toast notifications). The deployment workflow is described exclusively using Visual Studio and Azure WebJobs, both of which are Windows-centric tools. There are no Linux, cross-platform, or non-Windows examples, nor is there mention of how to implement or deploy the solution on Linux or using non-Windows tools.
Recommendations:
- Add equivalent sample code and instructions for Linux environments, such as using .NET Core/6+ on Linux, or alternative languages (e.g., Python, Node.js) that are cross-platform.
- Provide examples of deploying the backend listener as an Azure Function or containerized service, which can be developed and run on Linux as well as Windows.
- Include instructions for command-line deployment and management (e.g., using Azure CLI, Bash scripts) instead of or in addition to Visual Studio and right-click workflows.
- Demonstrate how to send notifications to non-Windows mobile platforms (e.g., Android, iOS) using Notification Hubs, with relevant code samples.
- Explicitly mention cross-platform options and clarify which steps are Windows-specific, offering alternatives where possible.
Create pull request
Flagged Code Snippets
private async void InitNotificationsAsync()
{
var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
var hub = new NotificationHub("[HubName]", "[DefaultListenSharedAccessSignature]");
var result = await hub.RegisterNativeAsync(channel.Uri);
// Displays the registration ID so you know it was successful
if (result.RegistrationId != null)
{
var dialog = new MessageDialog("Registration successful: " + result.RegistrationId);
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
}
}
static async Task ReceiveMessageAndSendNotificationAsync(string connectionString)
{
// Initialize the Notification Hub
string hubConnectionString = ConfigurationManager.AppSettings.Get
("Microsoft.NotificationHub.ConnectionString");
hub = NotificationHubClient.CreateClientFromConnectionString
(hubConnectionString, "enterprisepushservicehub");
ServiceBusClient Client = new ServiceBusClient(connectionString);
ServiceBusReceiver receiver = Client.CreateReceiver(topicName, subscriptionName);
// Continuously process messages received from the subscription
while (true)
{
ServiceBusReceivedMessage message = await receiver.ReceiveMessageAsync();
var toastMessage = @"<toast><visual><binding template=""ToastText01""><text id=""1"">{messagepayload}</text></binding></visual></toast>";
if (message != null)
{
try
{
Console.WriteLine(message.MessageId);
Console.WriteLine(message.SequenceNumber);
string messageBody = message.Body.ToString();
Console.WriteLine("Body: " + messageBody + "\n");
toastMessage = toastMessage.Replace("{messagepayload}", messageBody);
SendNotificationAsync(toastMessage);
// Remove message from subscription
await receiver.CompleteMessageAsync(message);
}
catch (Exception)
{
// Indicate a problem, unlock message in subscription
await receiver.AbandonMessageAsync(message);
}
}
}
}
static async void SendNotificationAsync(string message)
{
await hub.SendWindowsNativeNotificationAsync(message);
}