- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用本文档中提供的 REST API 向服务总线队列发送消息: https://learn.microsoft.com/en-us/rest/api/servicebus/send-message-to-queue
请注意,我无法使用 Azure 库来执行此任务,因为据我所知,没有可用的 Service Now,并且我正在 Python 中设置测试触发器来模拟从 Service 进行的 REST API 调用现在。
我对 storage queues 有类似的问题我尝试重用相同的解决方案,但服务总线会响应“缺少授权 header ”这是我在 header 中使用授权的代码:
import requests
api = f"https://{service_namespace}.servicebus.windows.net/{queue}/messages?"
msg = """<QueueMessage>
<MessageText>Testing 1234</MessageText>
</QueueMessage>
"""
header = {
"Authorization": f"SharedAccessSignature sr=https://{service_namespace}.servicebus.windows.net/{queue}&sig={sig}&se={se}&skn={skn}",
"Content-Type": "application/atom+xml;type=entry;charset=utf-8"
}
resp = requests.post(api, data=msg, headers=header)
print(resp)
print(resp.text)
print(resp.headers)
这里,sig
是我从共享访问策略下的服务总线队列获得的主键
se
是从现在起 2 年后的纪元时间(不含毫秒)skn
是策略的名称
我得到的最终回复是
<Response [401]>
{'Content-Length': '0', 'Server': 'Microsoft-HTTPAPI/2.0', 'Strict-Transport-Security': 'max-age=31536000', 'Date': 'Thu, 24 Feb 2022 09:27:17 GMT'}
如果我在标题中没有身份验证的情况下发布并使用上面突出显示的问题中的解决方案,顺便说一句,这是 API 结构:f"https://{service_namespace}.servicebus.windows.net/{queue}/messages?sig={sig}&se={se}&skn={skn}"
我收到此错误:
<Error><Code>401</Code><Detail>MissingToken: The authorization header was not found. To know more visit https://aka.ms/sbResourceMgrExceptions. . TrackingId:<redacted>, SystemTracker:<redacted>.servicebus.windows.net:<redacted>/messages, Timestamp:2022-02-24T09:31:09</Detail></Error>
{'Transfer-Encoding': 'chunked', 'Content-Type': 'application/xml; charset=utf-8', 'Server': 'Microsoft-HTTPAPI/2.0', 'Strict-Transport-Security': 'max-age=31536000', 'Date': 'Thu, 24 Feb 2022 09:31:09 GMT'}
我不知道如何继续此操作,任何提示和建议将不胜感激。
最佳答案
您收到此错误的原因是您错误地计算了共享访问签名。您可以了解更多here
.
要使用 python 生成 SAS token ,请参阅下面的代码,该代码摘自 here
:
import time
import urllib
import hmac
import hashlib
import base64
def get_auth_token(sb_name, eh_name, sas_name, sas_value):
"""
Returns an authorization token dictionary
for making calls to Event Hubs REST API.
"""
uri = urllib.parse.quote_plus("https://{}.servicebus.windows.net/{}" \
.format(sb_name, eh_name))
sas = sas_value.encode('utf-8')
expiry = str(int(time.time() + 10000))
string_to_sign = (uri + '\n' + expiry).encode('utf-8')
signed_hmac_sha256 = hmac.HMAC(sas, string_to_sign, hashlib.sha256)
signature = urllib.parse.quote(base64.b64encode(signed_hmac_sha256.digest()))
return {"sb_name": sb_name,
"eh_name": eh_name,
"token":'SharedAccessSignature sr={}&sig={}&se={}&skn={}' \
.format(uri, signature, expiry, sas_name)
}
关于python - 如何使用 SAS 对服务总线的 Azure REST API 进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71249890/
有没有办法从 .sas 文件中打开 SAS 数据集进行查看(即在“ViewTable”窗口中)? 最佳答案 我认为这会做你想做的: dm log "vt sashelp.air"; 只需更改 "sas
如何在 SAS 程序中将 sas 数据表 (sas7bdat) 设置为只读? — 即使在 session 之间,该表也必须保持只读状态,尤其是当另一个用户注册该库并尝试写入数据集时。一旦创建了这些表,
如何将 mmddyy 变量转换为 date9 变量?例如,假设我们有以下内容: x = 05/10/2011 我希望 x 的形式为 10May2011。所以我做了以下事情: xnew =
我正在使用以下代码将文本文件导入 SAS: proc import datafile="C:\Users\Desktop\data.txt" out=Indivs dbms=dlm replace;
您好,我有兴趣为我在 SAS 中生成的数据制作一些稍微复杂的自定义格式。我需要它是数字类型。 格式 1 0="-" >0="%" %" 即 0 >>>>>>> - .74 >>>>> 74% -.65
我正在尝试弄清楚如何读取文本文件 (300mb) 中以逗号分隔但数据位于一行中的数据。 数据看起来像这样: a,b,c,d,e,f,g,h,i,j,k,l,m,false,false,true,1,3
我想将 SAS 数据集从 SAS 导出到 FTP。我可以使用以下命令导出 csv 文件(或 txt 文件): %macro export_to_ftp(dsn= ,outfile_name= ); F
这个问题在 SAS forum 上讨论过,与会者最终同意不同意。 问题很简单:SAS 在编译时为所有变量分配一个缺失值UNLESS一个变量出现在sum 语句中(在这种情况下,SAS 在编译时分配了一个
众所周知,SAS需要特别注意句子中的引号。 例如 %let quoted="I'd like to"; data temp; set temp; quoted=""ed"; r
我对 SAS 完全陌生,我很绝望。 所以,我的代码是: DATA abc; INPUT AA BB CC DD EE; CARDS; ; RUN; PROC PRINT DATA = abc; T
我在使用如下所示的数据集时遇到问题。它是不同位置/周的库存计数: data have; input itm location $ week inv; cards; 3 x 1 30 3 x 2
我们需要确定我们现在使用的是什么类型的 SAS(pc SAS 或服务器 SAS)。有什么方法可以找出我们使用的是什么 SAS,是指 PC SAS 还是 SAS Server? 最佳答案 使用“proc
假设我有一个包含 n 行和 p 列的数据集,这样数据集中的每个条目都包含一个实数。我正在寻找一种方法来对每行中的 p 列进行排名。这个排名的输出应该是一个长度 - p 的排名向量,它说明了关系。 所以
我正在尝试打印一个带分隔符的文件,而不必指定所有列。我可以接近,但数字列总是被引用: DATA _NULL_; SET SASHELP.CARS (obs = 5 keep = Make Mode
SAS 软件可以成功读取的最大文件大小是多少。(不考虑硬件限制) 提前致谢。 最佳答案 引用最近播放的电视广告,答案是“无限加 1”。 SAS 在读取操作期间对文件的大小没有任何限制,尽管您可能会遇到
我有一个包含变量 y、x1 和 x2 的数据集。我想找到适合模型的方程式: y = k1*x1c1 + k2 *x2c2 通过找到 k1、c1、k2 和 c2。我如何在 SAS 中执行此操作?具体来说
SAS中是否有用于定义数组中字母序列的简写? 许多语言都具有轻松执行此操作的机制,我想SAS也是如此,尽管我找不到它的引用。 例如,在R中,我可以做 > x x [1] "a" "b" "c" "d
我有两个 SAS 数据集。第一个相对较小,包含唯一的日期和相应的 ID: date dateID 1jan90 10 2jan90 15 3jan90 20 ... 第二个
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我有一个主要是数值的变量,但是偶尔会有一个字符偷偷进入。因此,变量在 SAS 中存储为字符。我希望能够确定此字符变量中的各个值是否为数字。在知道哪些值是数字哪些是字符后,我想创建一个新的(数字)变量,
我是一名优秀的程序员,十分优秀!