我已经利用 HTTP 触发器实现了一个 Azure 函数,并与 SendGrid 集成。预期的操作是通过 HTTP 将数据传递到 Azure Function,并通过电子邮件将该内容发送到指定的收件箱。我的 Azure Function 在 Azure 门户中测试成功。换句话说,当我提交此内容时,收件箱会收到预期的电子邮件:
但是,当我尝试通过 Postman 发布到 Azure Function 时,我收到状态 400“错误请求 - 无效主机名”。我尝试利用我的功能键,将键作为 Postman 中 URI 中的参数传递,或者在标头中作为“x-functions-key”传递。状态始终为 400。我通过单击“获取函数 URL”从 Azure 门户获取要发布的 URL。作为替代方案,我还尝试发布到符合以下条件的 URL:
这是我的函数绑定(function.json):
{
"bindings": [
{
"authLevel": "function",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"methods": [
"get",
"post"
]
},
{
"type": "sendGrid",
"name": "$return",
"direction": "out",
"apiKey": "SendGridKey",
"from": "email@email.com",
"to": "email@email.com"
}
]
}
Run Code Online (Sandbox Code Playgroud)
这是函数逻辑(run.csx):
#r "Newtonsoft.Json"
#r "SendGrid"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using …Run Code Online (Sandbox Code Playgroud) 我正在尝试将图像保存到我们的 Azure 博客存储中。感谢通过代码片段下面的链接提供的有用响应,我能够成功地将文件保存到我们的顶级容器中。不幸的是,我希望将文件保存到该容器中的子目录中。而且,在我的一生中,我无法让它发挥作用。
目前,图像正在保存到我们的“images”容器中。该容器内有一个文件夹“members”。我希望将文件保存到该子目录中。所以“图像/成员”。我尝试将“images/members”传递给 GetBlockBlobReference 但文件根本没有保存(或者,至少我找不到它)。
这看起来应该很简单。提前致谢。
CloudBlobClient blobClient = account.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("images");
CloudBlockBlob blockBlob = container.GetBlockBlobReference(filename);
blockBlob.UploadFromStream(stream);
Run Code Online (Sandbox Code Playgroud)