使用 Azure 服务总线生成 RSS 源

Use Azure Service Bus to produce RSS feed

我希望让客户使用 RSS Reader.

订阅 Azure 服务总线上的主题

我似乎找不到有关如何开始从服务总线动态生成提要的文档

谁能给我指点一下?

Service Bus 在命名空间的根部自行生成一个 ATOM 提要,称为“服务注册表”。它位于 https://yournamespace.servicebus.windows.net,当您使用浏览器。

要探索命名空间提要(它是 ATOM 提要的嵌套结构),您需要在 "Authorization" 或 "ServiceBusAuthorization" 中为命名空间的根提供一个 SAS token with "Manage" access header 的 HTTP GET 请求。标准 "RootManageSharedAccessKey" 规则具有该权利。

    class Program
    {
        static void Main(string[] args)
        {
            // for connection string: 
            // Endpoint=sb://[[yournamespace]].servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=[[key]]

             var tp = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", "[[key]]");
            var token = tp.GetWebTokenAsync("http://[[yournamespace]].servicebus.windows.net/", string.Empty, true, TimeSpan.FromHours(1))
                .GetAwaiter()
                .GetResult();
            Console.WriteLine(token);
        }
    }

在控制台应用程序中使用上面的代码片段(使用 SB NuGet 包),您将获得所需的令牌字符串以放入 HTTP header。

当我在 HTTP "Authorization:" header 中将该令牌与我在 Fiddler 的作曲家中的一个命名空间一起用于根目录上的 HTTPS GET 时,我得到

<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="text">Publicly Listed Services</title>
  <subtitle type="text">This is the list of publicly-listed services currently available.</subtitle>
  <id>uuid:f1ccc436-e5bb-47f7-b780-a7d06e942d51;id=843</id>
  <updated>2016-01-05T12:30:33Z</updated>
  <generator>Service Bus 1.1</generator>
  <entry>
    <id>uuid:f1ccc436-e5bb-47f7-b780-a7d06e942d51;id=844</id>
    <title type="text">democtrl</title>
    <updated>2016-01-05T12:30:34Z</updated>
    <link rel="alternate" href="http://clemensveu.servicebus.windows.net/democtrl"/>
  </entry>
  <entry>
    <id>uuid:f1ccc436-e5bb-47f7-b780-a7d06e942d51;id=845</id>
    <title type="text">hshsjsjshjshsjhsjhs</title>
    <updated>2016-01-05T12:30:34Z</updated>
    <link rel="alternate" href="http://clemensveu.servicebus.windows.net/hshsjsjshjshsjhsjhs"/>
  </entry>
  <entry>
    <id>uuid:f1ccc436-e5bb-47f7-b780-a7d06e942d51;id=846</id>
    <title type="text">iotev2</title>
    <updated>2016-01-05T12:30:34Z</updated>
    <link rel="alternate" href="http://clemensveu.servicebus.windows.net/iotev2"/>
  </entry>
  <entry>
    <id>uuid:f1ccc436-e5bb-47f7-b780-a7d06e942d51;id=847</id>
    <title type="text">samplequeue</title>
    <updated>2016-01-05T12:30:34Z</updated>
    <link rel="alternate" href="http://clemensveu.servicebus.windows.net/samplequeue"/>
  </entry>
  <entry>
    <id>uuid:f1ccc436-e5bb-47f7-b780-a7d06e942d51;id=848</id>
    <title type="text">stelemetryqueue</title>
    <updated>2016-01-05T12:30:34Z</updated>
    <link rel="alternate" href="http://clemensveu.servicebus.windows.net/stelemetryqueue"/>
  </entry>
  <entry>
    <id>uuid:f1ccc436-e5bb-47f7-b780-a7d06e942d51;id=849</id>
    <title type="text">testqueue</title>
    <updated>2016-01-05T12:30:34Z</updated>
    <link rel="alternate" href="http://clemensveu.servicebus.windows.net/testqueue"/>
  </entry>
</feed>

并且在遵循测试队列的 link 时(但使用 HTTPS 来保护令牌),我得到

<entry xmlns="http://www.w3.org/2005/Atom">
  <id>https://clemensveu.servicebus.windows.net/testqueue</id>
  <title type="text">testqueue</title>
  <published>2015-09-07T09:33:46Z</published>
  <updated>2015-09-07T09:34:17Z</updated>
  <author>
    <name>clemensveu</name>
  </author>
  <link rel="self" href="https://clemensveu.servicebus.windows.net/testqueue"/>
  <content type="application/xml">
    <QueueDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <LockDuration>PT30S</LockDuration>
      <MaxSizeInMegabytes>16384</MaxSizeInMegabytes>
      <RequiresDuplicateDetection>false</RequiresDuplicateDetection>
      <RequiresSession>false</RequiresSession>
      <DefaultMessageTimeToLive>P14D</DefaultMessageTimeToLive>
      <DeadLetteringOnMessageExpiration>false</DeadLetteringOnMessageExpiration>
      <DuplicateDetectionHistoryTimeWindow>PT10M</DuplicateDetectionHistoryTimeWindow>
      <MaxDeliveryCount>10</MaxDeliveryCount>
      <EnableBatchedOperations>true</EnableBatchedOperations>
      <SizeInBytes>1550</SizeInBytes>
      <MessageCount>5</MessageCount>
    </QueueDescription>
  </content>
</entry>