如何使用PNS反馈服务返回的“ Azure存储容器URL”?

问题描述

我正在尝试获取有关推送通知的反馈,如此处所述:https://docs.microsoft.com/en-us/previous-versions/azure/reference/mt705560(v=azure.100)

成功后,将返回带有身份验证令牌的Azure存储容器URL。

我有以下网址:

https://pushpnsfb9bf61499e7c8fe.blob.core.windows.net/00000000002002698042?sv=2015-07-08&sr=c&sig=KbF1GtORNzAaCZH9UP7UFi9wMOYBmBgL%2BXLG3Qau9U0%3D&se=2020-08-29T19:10:17Z&sp=rl

但是请求它会返回验证错误

<Error>
    <Code>AuthenticationFailed</Code>
    <Message>Server Failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature...</Message>
    <AuthenticationErrorDetail>Signature did not match. String to sign used was... </AuthenticationErrorDetail>
</Error>

我正在尝试关注https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-service-sas-create-dotnet?tabs=dotnet#create-a-service-sas-for-a-blob-container上的文档。该网址包含sr=c,这似乎意味着我需要“用于blob容器的SAS”。

但是我从哪里获得令牌?返回的URL具有一个sig querystring参数-我尝试使用该参数对请求进行签名,但是没有用。

我在做什么错了?

解决方法

当我们调用获取平台通知服务(PNS)反馈rest api时,我们将获得带有sas令牌的容器url。并且sas令牌在容器级别具有读取和列出权限。因此,我们可以使用azure blob rest api读取容器中任何blob的内容,属性,元数据或阻止列表,或使用令牌列出容器中的blob。有关更多详细信息,请参阅here

例如

  1. 获取容器网址 enter image description here

  2. 测试 一种。列出斑点

GET https://pushpnsfb2f34ecd6733e74.blob.core.windows.net/00000000002000276266?
<sas token e.t. sv=2015-07-08&sr=c&sig=SQodHcRM6p04ag9rJZBqPDmr1NMd%2FbIWoPzMZrB9TpI%3D&se=2020-09-02T05%3A28%3A07Z&sp=rl>
 &restype=container&comp=list

enter image description here

b。读取Blob内容

GET GET https://pushpnsfb2f34ecd6733e74.blob.core.windows.net/00000000002000276266/<blob name>?
<sas token e.t. sv=2015-07-08&sr=c&sig=SQodHcRM6p04ag9rJZBqPDmr1NMd%2FbIWoPzMZrB9TpI%3D&se=2020-09-02T05%3A28%3A07Z&sp=rl>

有关Azure Blob rest api的更多详细信息,请参阅here