- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
好吧,我意识到 webjobs sdk 仍处于测试阶段,但它非常酷。尽管在获取我要绑定(bind)的实际对象方面,我在使用 IBinder 方面遇到了一些困难。这可能是显而易见的,所以请原谅我……
我正在处理要通过网络作业发送的电子邮件。它们被放入队列并触发事件。这段代码有效..但我不禁想到我可以访问生成的 blob,如果成功则删除它,或者如果失败则移动它,更容易。
这是代码:
public static void ProcessEmailBlob([QueueTrigger(Email.queueEmailsToSend) ] string blobname, IBinder binder)
{
TextReader inputfile = binder.Bind<TextReader>(new BlobAttribute(Email.blobEmailOutboxContainerAsPath+blobname));
string input = inputfile.ReadToEnd();
string connection = ConfigurationManager.ConnectionStrings["AzureJobsStorage"].ConnectionString;
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connection);
//Get create connect to the outbox blob
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(Email.blobEmailOutboxContainer);
CloudBlockBlob emailin = container.GetBlockBlobReference(blobname);
MailMessage smptmail = new MailMessage();
//ought to be able to JSONise this??
//smptmail = JsonConvert.DeserializeObject<MailMessage>(input);
smptmail = XmlMailMessage.MakeSMPTMessage(input);
bool success = Email.Send(smptmail);
if (success && emailin.Exists()) //If sending the email succeeded
{
emailin.Delete();
}
else
{ //The email failed or the blob doesn't exist which is also odd and bad
if (emailin.Exists())
{ //Then the file is ok.. store it in the Failed Email
CloudBlobContainer failedcontainer = blobClient.GetContainerReference(Email.blobEmailFailedContainer);
failedcontainer.CreateIfNotExists();
CloudBlockBlob failedmailblob = failedcontainer.GetBlockBlobReference(blobname); // use the same name just a different container
failedmailblob.StartCopyFromBlob(emailin);
}
else
{
//log something here
}
}
}
正如你所看到的,我可以使用binder.Bind片段获取blob内容,但是然后我需要执行整个连接操作才能删除它..这是不对的..可以吗?
最佳答案
BlobAttribute 也可用于 .NET SDK 类型。在您的情况下,您可以绑定(bind)到 CloudBlockBlob,然后就不需要连接字符串。
CloudBlockBlob blobReference = binder.Bind<CloudBlockBlob>(new BlobAttribute(Email.blobEmailOutboxContainerAsPath+blobname));
blobReference.DeleteIfExists();
顺便说一句,您还可以绑定(bind)到 CloudStorageAccount。如果您的网络作业有 CloudStorageAccount 参数(无需属性),它将被神奇地绑定(bind)。
关于azure - webjobs 使用 IBinder 删除 blob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24787535/
我正在尝试测试具有以下定义的事件函数: [FunctionName(nameof(LoadReferenceFromBlobStorage))] public static async Task Ru
我的问题很简单,但我已经为此苦苦挣扎了很长时间! 我有一个调用 onBound() 方法的绑定(bind)服务: @Override public IBinder onBind(Intent
我看到了枚举给定服务(类型)的绑定(bind)列表的方法,但我找不到返回已加载模块中绑定(bind)的所有内容列表的方法。我正在寻找类似Kernel::IEnumerable GetAllRegist
我想找到一个 MethodInitation 的声明节点: MethodInvocation methodNode = ...; IMethodBinding b = methodNode.resol
我有一个由多种类型实现的接口(interface)。但在我做 kernel.GetAll() 之前我希望能够思考注入(inject)的目标类型。 我知道函数 kernel.GetBindings(ty
好吧,我意识到 webjobs sdk 仍处于测试阶段,但它非常酷。尽管在获取我要绑定(bind)的实际对象方面,我在使用 IBinder 方面遇到了一些困难。这可能是显而易见的,所以请原谅我…… 我
我想知道 AIDL 比广播接收器更好的用例,反之亦然。同样,Ibinder 比广播接收器和 AIDL 更好的用例 最佳答案 广播接收者 通信实体的类型:主要是不同的应用。 通信由:发件人触发 接收通信
是否可以在以 TypeScript 或 JavaScript 运行的 Azure 函数中使用 IBinder 功能(或者模仿它的最佳方法是什么)? https://learn.microsoft.co
我需要对通过IPC 从其他进程携带的IBinder 实例进行安全检查。这个IBinder的创建者/接收者可能不是携带它的IPC的直接调用者,所以我不能简单地使用Binder.getCallingUid
当我使用 startService(...) 启动服务时,我一直在寻找获取 ServiceConnection 的方法。 我还没有找到办法,所以我一直在寻找,发现了这个: Does each Acti
在给出的第三段代码的上下文中交谈 on this page , 有一个方法 Messenger named getBinder()返回 the IBinder Messenger 用于与 associ
如何将 FieldDeclaration(类型:ASTNode)转换为 IField(类型:JavaElement)。是否可以从 FieldDeclaration ASTNode 获取绑定(bind)
我想通过单击按钮在我的 EditText 上显示 Google 语音输入 IME。所以,根据this文章和source code我应该写这段代码 inputMethodManager.setInput
我的 Azure 函数场景: HTTP 触发器。 基于 HTTP 参数,我想从适当的存储队列读取消息并返回数据。 这是函数的代码(F#): let Run(request: string, custo
我的 Azure 函数场景: HTTP 触发器。 基于 HTTP 参数,我想从适当的存储队列读取消息并返回数据。 这是函数的代码(F#): let Run(request: string, custo
最近我将我的应用程序迁移到 targetSdkVersion = 28。 将更新后的应用程序发布到 Google Play 后,我开始在 Fabric.io 中收到非常奇怪的崩溃报告: Crash r
我是一名优秀的程序员,十分优秀!