![](/img/trans.png)
[英]How to use Azurite blob containers as Azure Function internal storage and as trigger?
[英]Azure Function to get image from Blob Storage stopped working on Local Azure Emulator (Azurite)
简单 Azure function 从存储中获取图像...
[FunctionName("GetImage")]
public static IActionResult GetImage(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "image/{fileName}")] HttpRequest req,
[Blob("images/{fileName}", FileAccess.Read, Connection = "BlobConnection")] Stream blob,
ILogger log, string fileName)
{
log.LogInformation("Get file from blob " + fileName + " length: " + blob.Length);
MemoryStream ms = new MemoryStream();
blob.CopyTo(ms);
return new FileContentResult(ms.ToArray(), "image/jpeg");
}
工作得很好,但我遇到了一个问题:无法启动 azure 函数(内部 500 错误 - blob 存储问题)。
附加配置参数似乎可以解决初始化问题:
"AzureWebJobsSecretStorageType": "files"
不幸的是,现在 function 在执行时不起作用:
Executed 'GetImage' (Failed, Duration=26013ms)
System.Private.CoreLib: Exception while executing function: GetImage. Azure.Storage.Blobs: Service request failed.
Status: 500 (Internal Server Error)
Inner source of Exception: Azure.Storage.Blobs.BlobRestClient.Download(...
有任何想法吗? 提前致谢。
使用 Microsoft Azure 存储资源管理器连接到 Azurite。 那里没有问题。
Azure 功能核心工具核心工具版本:4.0.4915 提交 hash:N/A(64 位)Function 运行时版本:4.14.0.19631
抛出的异常:blob.CopyTo(ms):
Azure.RequestFailedException:服务请求失败。
状态:500(内部服务器错误)
标头:
服务器:Azurite-Blob/3.20.1
x-ms-creation-time:2022 年 11 月 30 日星期三 12:55:17 GMT
ETag:“0x1D64FE85292CAC0”
x-ms-blob 类型:BlockBlob
x-ms-lease-state:可用
x-ms-lease-status: 解锁
x-ms-client-request-id: 6e6dff50-8c8b-4ccd-bb76-e9b460008293
x-ms-请求-id:91976feb-4421-47a3-9a0e-16a26dc6ad70
x-ms-版本:2021-10-04
接受范围:字节
日期:2022 年 12 月 15 日星期四 08:46:32 GMT
x-ms-server-encrypted: true
x-ms-blob-content-md5: 3KQmtVIakH8iR9D9PlFbSg==
连接:保持活动状态
保持活动状态:已编辑
最后修改时间:2022 年 11 月 30 日星期三 12:55:17 GMT
内容长度:18304
内容类型:图像/jpeg
内容范围:字节 0-18303/18304
内容-MD5:3KQmtVIakH8iR9D9PlFbSg==
内容处置:
在 Azure.Storage.Blobs.BlobRestClient.Download(字符串快照,字符串 versionId,可空1 timeout, String range, String leaseId, Nullable
1 rangeGetContentMD5,可空1 rangeGetContentCRC64, String encryptionKey, String encryptionKeySha256, Nullable
1 encryptionAlgorithm,可空1 ifModifiedSince, Nullable
1 ifUnmodifiedSince, String ifMatch, String ifNoneMatch, String ifTags, CancellationToken cancellationToken) at Azure.Storage.Blobs.Specialized.BlobBaseClient.StartDownloadAsync(HttpRange range, BlobRequestConditions conditions, Boolean rangeGetContentHash, Int64 startOffset, Boolean async, CancellationToken cancellationToken) at Azure.Storage .Blobs.Specialized.BlobBaseClient.DownloadStreamingInternal(HttpRange range, BlobRequestConditions conditions, Boolean rangeGetContentHash, IProgress`1 progressHandler, String operationName, Boolean async, CancellationToken cancellationToken) at Azure.Storage.Blobs d.BlobBaseClient.<>c__DisplayClass92_0.<b__0>d.MoveNext()
--- 从上一个位置开始的堆栈跟踪结束 ---
at Azure.Storage.LazyLoadingReadOnlyStream 1.DownloadInternal(Boolean async, CancellationToken cancellationToken) at Azure.Storage.LazyLoadingReadOnlyStream
1.ReadInternal(Byte[] buffer, Int32 offset, Int32 count, Boolean async, CancellationToken cancellationToken) at Azure.Core.Pipeline. TaskExtensions.EnsureCompleted[T](Task 1 task) at Azure.Storage.LazyLoadingReadOnlyStream
(Byte[] buffer, Int32 offset, Int32 count) at System.IO.Stream.CopyTo(Stream destination, Int32 bufferSize) at System.IO.Stream. CopyTo(Stream destination) at StandardFunctions.BloobFunctions.GetImage(HttpRequest req, Stream blob, ILogger log, String fileName) 在 C:\Dev\StandardFunctions\BloobFunctions.cs:line 39
全新安装 OS 和 VS。 具有相同配置的相同代码工作正常:/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.