刚接触 ACS,我只想发送短信。官方的 MS 示例不起作用。我收到 401 未经授权的错误。我尝试使用连接字符串构建客户端,就像示例一样,并且我尝试使用 DefaultAzureCredential。朝那个方向走会导致未知错误。有谁对如何让 ACS SMS SendAsync 调用正常工作有任何建议,或者让我知道我做错了什么?
确保
<from-phone-number>
设置为您之前使用电话号码功能注册的电话号码 sms:PhoneNumberCapabilityType.Outbound
。
var capabilities = new PhoneNumberCapabilities(sms:PhoneNumberCapabilityType.Outbound);
// ... register the phone number and use it in the following code:
SmsSendResult sendResult = smsClient.Send(
from: "<from-phone-number>",
to: "<to-phone-number>",
message: "Hello World via SMS"
);
请确保您使用的是付费订阅,而不是试用订阅,因为试用订阅不支持发送短信。我花了一整天的时间来追踪这个花絮: