netmfazureservicebus:用于与 Azure 服务(队列、主题和事件中心)通信的 .NET Micro Fram

  • b5_185304
    了解作者
  • 39.8KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-29 07:40
    上传日期
网络故障服务总线 用于与 Azure 服务(队列、主题和事件中心)通信的 .NET Micro Framework 库 学分 我从以下位置获得了 SAS 令牌生成器: : 非常感谢您的出色工作. 要求 .NET 微框架 4.3 视觉工作室 用于创建服务总线命名空间的 Azure 订阅 开始: 在 Azure 门户中创建新的服务总线命名空间 记下您的共享访问密钥,该密钥将在创建新的服务总线命名空间时自动生成。 完成这两个步骤后,您就可以开始了。 库的示例用法: 首先,您必须使用服务总线命名空间、共享访问密钥名称和共享访问密钥创建 ServiceBusAccount 类的新实例。 var account = new ServiceBusAccount ( " test-ns-1 " , " RootManageSha
netmfazureservicebus-master.zip
  • netmfazureservicebus-master
  • TestConsoleApp
  • Properties
  • AssemblyInfo.cs
    855B
  • Resources.Designer.cs
    1.2KB
  • Program.cs
    4.4KB
  • OnBoardFlash.dat.smd
    89KB
  • OnBoardFlash.dat
    11.1MB
  • TestConsoleApp.csproj
    2.6KB
  • Resources.resx
    5.6KB
  • netmfazureservicebus
  • SBProperties
  • BrokerProperties.cs
    2.9KB
  • EventHubs
  • EventHubClient.cs
    3.8KB
  • Topics
  • TopicClient.cs
    3.4KB
  • Helper
  • AzureHttpHelper.cs
    2.3KB
  • Properties
  • AssemblyInfo.cs
    867B
  • Account
  • ServiceBusAccount.cs
    566B
  • Queues
  • QueueClient.cs
    3.4KB
  • Utilities
  • SAS.cs
    1.9KB
  • SHA.cs
    7.7KB
  • StringUtility.cs
    315B
  • HttpUtility.cs
    4.6KB
  • netmfazureservicebus.csproj
    2.6KB
  • LICENSE
    11.1KB
  • netmfazureservicebus.sln
    1.6KB
  • README.md
    3.1KB
  • .gitignore
    2.6KB
内容介绍
netmfazureservicebus ==================== A .NET Micro Framework library for communicating with Azure Service (Queues, Topics and Event Hubs) #### Credits --- I have gotten the SAS Token Generator from: http://blog.devmobile.co.nz/2014/11/30/azure-event-hub-updates-from-a-netmf-device/ so great thanks for the great work. #### Requirements --- * .NET Micro Framework 4.3 * Visual Studio * An Azure Subscription to create a Service Bus Namespace #### Get Started: --- * Create a new Service Bus Namespace inside the Azure Portal * Take note of your Shared Access Key which will be automatically generate when creating a new Service Bus Namespace. After these two steps your are ready to start. ### Example Usage of the library: --- At first you have to create a new Instance of the ServiceBusAccount Class with your Service Bus Namespace, your Shared Access Key Name and your Shared Access Key. ```c# var account = new ServiceBusAccount( "test-ns-1", "RootManageSharedAccessKey", "ieDIqTtF24fgxu4nRMFHauo4U7+NMqweoyOmzrMVQ1="); ``` After this you could work with one of the three Service Bus Items (Queues, Topics and Event Hubs) I am only showing Queues here in the readme, but the other two are nearly identical and you could it out in the Test Application. ---- We are now creating a new Instance of the EventHubClient: ```c# var queueClient = new QueueClient(account); ``` #### Create a new queue You could now create a new queue directly from your device. The method returns a bool to check if the creation process was successfull. ```c# if (queueClient.CreateQueue("test-queue1")) { Debug.Print("Queue successfully created"); } ``` #### Send a message to the new queue We will now dispatch a message into the newly created queue. ```c# queueClient.BrokerProperties.Label = "Testlabel"; queueClient.BrokerProperties.CorrelationId = "NewId"; queueClient.BrokerProperties.ForcePersistence = true; queueClient.BrokerProperties.TimeToLive = new TimeSpan(0, 3, 22); queueClient.CustomProperties.Add("Customer", "MS"); queueClient.CustomProperties.Add("Importance", "High"); if (queueClient.SendMessage("Hello from netmf", "test-queue1")) { Debug.Print("Message to Queue successfully sent"); } ``` There are two collections inside the QueueClient. One of this is Brokerproperties which is a nearly identical Implementation of the BrokeredProperties Class inside the ServiceBusClient (http://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.brokeredmessage_properties.aspx) and a HashTable called "CustomProperties" where you could any custom Properties you want to send inside the message. After you have added your properties you could now add an inside body for the message via the first parameter and send it to the queue. #### Delete the new queue After all our Tests are finished we will now delete the queue. ```c# if (queueClient.DeleteQueue("test-queue1")) { Debug.Print("Queue successfully deleted"); } ``` After all your tests are finished you are ready to go and implement this into your application. I am happy to see your implemntations and hear about that. You could contact me on Twitter: @mobernberger
评论
    相关推荐