简体   繁体   English

Azure Function 从 Blob 存储获取图像停止在本地 Azure 模拟器 (Azurite) 上工作

[英]Azure Function to get image from Blob Storage stopped working on Local Azure Emulator (Azurite)

Simple Azure function to get image from storage...简单 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");
        }

Worked just fine, than I faced an issue: can't start azure functions (Internal 500 Error - problem with blob storage).工作得很好,但我遇到了一个问题:无法启动 azure 函数(内部 500 错误 - blob 存储问题)。

Additional configuration parameter seems to resolve initialization issue:附加配置参数似乎可以解决初始化问题:

"AzureWebJobsSecretStorageType": "files"

Unfortunately now function is not working when executed:不幸的是,现在 function 在执行时不起作用:

  1. It logs access with required file name and size.它使用所需的文件名和大小记录访问。
  2. It stops for around 25s on blob.CopyTo(ms) line.它在 blob.CopyTo(ms) 行停止了大约 25 秒。
  3. Error:错误:
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(...

Any ideas?有任何想法吗? Thanks in advance.提前致谢。

Connected to Azurite with Microsoft Azure Storage Explorer.使用 Microsoft Azure 存储资源管理器连接到 Azurite。 No issues there.那里没有问题。

Azure Functions Core Tools Core Tools Version: 4.0.4915 Commit hash: N/A (64-bit) Function Runtime Version: 4.14.0.19631 Azure 功能核心工具核心工具版本:4.0.4915 提交 hash:N/A(64 位)Function 运行时版本:4.14.0.19631

Exception thrown by: blob.CopyTo(ms):抛出的异常:blob.CopyTo(ms):

Azure.RequestFailedException: Service request failed. Azure.RequestFailedException:服务请求失败。

Status: 500 (Internal Server Error)状态:500(内部服务器错误)

Headers:标头:

Server: Azurite-Blob/3.20.1服务器:Azurite-Blob/3.20.1

x-ms-creation-time: Wed, 30 Nov 2022 12:55:17 GMT x-ms-creation-time:2022 年 11 月 30 日星期三 12:55:17 GMT

ETag: "0x1D64FE85292CAC0" ETag:“0x1D64FE85292CAC0”

x-ms-blob-type: BlockBlob x-ms-blob 类型:BlockBlob

x-ms-lease-state: available x-ms-lease-state:可用

x-ms-lease-status: unlocked x-ms-lease-status: 解锁

x-ms-client-request-id: 6e6dff50-8c8b-4ccd-bb76-e9b460008293 x-ms-client-request-id: 6e6dff50-8c8b-4ccd-bb76-e9b460008293

x-ms-request-id: 91976feb-4421-47a3-9a0e-16a26dc6ad70 x-ms-请求-id:91976feb-4421-47a3-9a0e-16a26dc6ad70

x-ms-version: 2021-10-04 x-ms-版本:2021-10-04

Accept-Ranges: bytes接受范围:字节

Date: Thu, 15 Dec 2022 08:46:32 GMT日期:2022 年 12 月 15 日星期四 08:46:32 GMT

x-ms-server-encrypted: true x-ms-server-encrypted: true

x-ms-blob-content-md5: 3KQmtVIakH8iR9D9PlFbSg== x-ms-blob-content-md5: 3KQmtVIakH8iR9D9PlFbSg==

Connection: keep-alive连接:保持活动状态

Keep-Alive: REDACTED保持活动状态:已编辑

Last-Modified: Wed, 30 Nov 2022 12:55:17 GMT最后修改时间:2022 年 11 月 30 日星期三 12:55:17 GMT

Content-Length: 18304内容长度:18304

Content-Type: image/jpeg内容类型:图像/jpeg

Content-Range: bytes 0-18303/18304内容范围:字节 0-18303/18304

Content-MD5: 3KQmtVIakH8iR9D9PlFbSg==内容-MD5:3KQmtVIakH8iR9D9PlFbSg==

Content-Disposition:内容处置:

at Azure.Storage.Blobs.BlobRestClient.Download(String snapshot, String versionId, Nullable 1 timeout, String range, String leaseId, Nullable 1 rangeGetContentMD5, Nullable 1 rangeGetContentCRC64, String encryptionKey, String encryptionKeySha256, Nullable 1 encryptionAlgorithm, Nullable 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.Specialize在 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() d.BlobBaseClient.<>c__DisplayClass92_0.<b__0>d.MoveNext()

--- End of stack trace from previous location --- --- 从上一个位置开始的堆栈跟踪结束 ---

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 1.Read(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) in C:\Dev\StandardFunctions\BloobFunctions.cs:line 39 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

Fresh installation of OS and VS.全新安装 OS 和 VS。 The same code with the same configuration is working just fine:/具有相同配置的相同代码工作正常:/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 Azurite blob 容器用作 Azure Function 内部存储和触发器? - How to use Azurite blob containers as Azure Function internal storage and as trigger? 基于 Blob 存储的 Azure 函数触发器无法与存储资源管理器/模拟器一起使用 - Blob Storage based Azure Function Trigger is not working with Storage Explorer/Emulator Azure 功能:Blob 存储模拟器在移动到 VS2022 后停止工作 - Azure Functions: Blob Storage emulator stopped working after moving to VS2022 从Azure功能连接到Azure Blob存储 - Connecting to Azure Blob Storage from an Azure Function 消息未从 Azure Function 添加到 Azurite 队列 - Message not added to Azurite Queue from Azure Function 使用 Azure Function 绑定从 Blob 存储中获取多个文件 - Get Multiple Files From Blob Storage With Azure Function Bindings 无法从 Azure 函数中的 azure.storage.blob 导入 AppendBlobService - Unable to import AppendBlobService from azure.storage.blob in Azure function 如何将 Azure 函数的 AzureWebJobsStorage 设置为 Azurite 存储? - How to set AzureWebJobsStorage of Azure Functions to Azurite storage? 在 python 中从 Azure Function 中的 Azure blob 存储读取数据 - Read data from Azure blob storage in Azure Function in python 无法从 Azure 存储帐户中删除 blob - Azure Function (Java) - Not able to delete blob from Azure storage Account - Azure Function (Java)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM