问题描述

创建一个PowerShell脚本的Azure Function,触发方式为 Storage Queue。但执行函数结果一直失败 (Failed).

错误消息为:

Executed 'Functions.QueueTrigger1' (Failed, Id=..., Duration=30ms) The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

Funciton 代码:

# Input bindings are passed in via param block.
param([string] $QueueItem, $TriggerMetadata) # Write out the queue message and metadata to the information log.
Write-Host "PowerShell queue trigger function processed work item: $QueueItem"
Write-Host "Queue item expiration time: $($TriggerMetadata.ExpirationTime)"
Write-Host "Queue item insertion time: $($TriggerMetadata.InsertionTime)"
Write-Host "Queue item next visible time: $($TriggerMetadata.NextVisibleTime)"
Write-Host "ID: $($TriggerMetadata.Id)"
Write-Host "Pop receipt: $($TriggerMetadata.PopReceipt)"
Write-Host "Dequeue count: $($TriggerMetadata.DequeueCount)"

通过向Storage Queue中添加消息时候触发:

az storage message put --content "This is a function test message" 

问题分析

根据错误消息,Function (Storage Queue)触发的消息需要 Base64编码,如发送 "This is a function test message"  这段消息,需要在发送消息时候转换为base64编码。

在CMD中调用PowerShell进行类型转换:

powershell "[convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(\"This is a function test message\"))"

在Powershell中直接转换:

[convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("This is a function test message"))

所以,修改后的向Storage Queue中添加消息的命令为:

$queuemsg = [convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("This is a function test message"))

az storage message put --content $queuemsg 

参考资料

适用于 Azure Functions 的 Azure 队列存储触发器: https://docs.azure.cn/zh-cn/azure-functions/functions-bindings-storage-queue-trigger?tabs=powershell#encoding

【Azure 应用服务】Storage Queue触发Azure Function时报错 The input is not a valid Base-64 string的更多相关文章

  1. 【Azure 应用服务】部署Kafka Trigger Function到Azure Function服务中,解决自定义域名解析难题

    问题描述 经过前两篇文章,分别使用VM搭建了Kafka服务,创建了Azure Function项目,并且都在本地运行成功. [Azure Developer]在Azure VM (Windows) 中 ...

  2. Azure File Storage 基本用法 -- Azure Storage 之 File

    Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table. 笔者在<Azure Blob Storage 基 ...

  3. Azure Blob Storage 基本用法 -- Azure Storage 之 Blob

    Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table. 笔者在<Azure Table storage ...

  4. Azure Table storage 基本用法 -- Azure Storage 之 Table

    Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table,其中的 Table 就是本文的主角 Azure Tabl ...

  5. 【Azure 应用服务】App Service/Azure Function的出站连接过多而引起了SNAT端口耗尽,导致一些新的请求出现超时错误(Timeout)

    问题描述 当需要在应用中有大量的出站连接时候,就会涉及到SNAT(源地址网络转换)耗尽的问题.而通过Azure App Service/Function的默认监控指标图表中,却没有可以直接查看到SNA ...

  6. 使用版本 1.0.0 的 Azure ARM SDK for Java 创建虚拟机时报错

    问题描述 我们可以通过使用 Azure ARM SDK 来管理 Azure 上的资源,因此我们也可以通过 SDK 来创建 ARM 类型的虚拟机,当我们使用 1.0.0 版本的 Azure SDK fo ...

  7. 【Azure 应用服务】探索在Azure上设置禁止任何人访问App Service的默认域名(Default URL)

    问题描述 总所周知,Azure App Service服务会默认提供一个 ***.chinacloudsites.cn为后缀的域名,但是该域名由上海蓝云网络科技有限公司备案,仅用于向其客户提供 Azu ...

  8. hive udaf 用maven打包运行create temporary function 时报错

    用maven打包写好的jar,在放到hive中作暂时函数时报错. 错误信息例如以下: hive> create temporary function maxvalue as "com. ...

  9. 【Azure 应用服务】本地创建Azure Function Kafka Trigger 函数和Kafka output的HTTP Trigger函数实验

    问题描述 在上一篇博文(https://www.cnblogs.com/lulight/p/16525902.html)中,我们成功的以VM作为Kafka服务器运行,并且验证了从其他机器中远程访问.在 ...

  10. 远程访问Function时报错Remote table-valued function calls are not allowed.

    开始是这样调用的:select * from [LinkedServer].[db name].dbo.[function name](param1, param2) 原因: Only table-v ...

随机推荐

  1. kubeadm 搭建 k8s 时用到的常用命令汇总

    简单记录一下 kubeadm config images list 修改镜像名称 docker tag registry.cn-hangzhou.aliyuncs.com/google_contain ...

  2. Gin-官方文档

    目录 官方文档 官方文档 https://learnku.com/docs/gin-gonic/2018/gin-readme/3819 https://www.kancloud.cn/shuangd ...

  3. 微信小程序-页面跳转数据传递

    在之前的文章当中我们都实现了一个功能就是可以从上一个页面传递数据给下一个页面,那么我们能不能从下一个页面传递数据给上一个页面呢,答案是可以的. 所以说本文这次主要介绍的内容就是返回上一个页面时传递参数 ...

  4. 小白学k8s(6)使用kubespray部署k8s

    kubespray部署k8s 准备 需要关闭防火墙 配置hosts 处理镜像 配置文件 运行 通过对应的镜像 运行代码 查看结果 出现的问题 墙 错误的配置 kubespray部署k8s 准备 kub ...

  5. Mysql索引失效场景

    Mysql索引失效场景   序言   众所周知在Mysql中,通过使用索引的方式可以加快查询速度,从而避免全文搜索:而索引本身就像图书馆中所有书籍目录,通过查询关键字就能快速找到目标书籍在几列几行,这 ...

  6. C/C++ 使用API实现数据压缩与解压缩

    在Windows编程中,经常会遇到需要对数据进行压缩和解压缩的情况,数据压缩是一种常见的优化手段,能够减小数据的存储空间并提高传输效率.Windows提供了这些API函数,本文将深入探讨使用Windo ...

  7. a标签download属性跨域问题

    1.如果是加载了非同源的内容,该属性将失效,等于导航功能 2.在服务端设置Content-Disposition,使用HTTP响应头Content-disposition进行处理 3.先下载数据文件, ...

  8. JWT( JSON Web Token —— JSON Web 令牌 )的学习笔记

    一.跨域认证的问题 互联网服务离不开用户认证.一般流程是下面这样: 1.用户向服务器发送用户名和密码. 2.服务器验证通过后,在当前对话(session)里面保存相关数据,比如用户角色.登录时间等等. ...

  9. CH59X/CH58X/CH57X 片上flash的使用

    以CH592F为例:在使用时先看手册对code和data区的划分 一.DataFlash的读写的操作 先看几个操作dataflash的API(读擦写): /** * @brief read Data- ...

  10. 常用容器:动态数组array、列表list、队列 queue、map或字典、 集合、栈等等

    一般语言都会提供一些逻辑容器的实现,各个语言的实现方式不同:底层的数学算法应该差不多: 动态数组 `` 这个没啥可说的,就是一个数组,满了时候,再创建一个数组,把之前的数组里的数据移过来,销毁之前数组 ...