Azurite 不适用于 VS Code 中的 Blob 触发器

问题描述

我创建了一个在本地运行的函数,我可以为 HTTP 触发函数执行此操作,但是当涉及到 BlobTriggered 时,我总是遇到相同的错误

我正在使用 Azurite 在 http://127.0.0.1:10000 端点模拟 Azure 中的 Blob 服务 我的代码如下:

local.settings.json

{
  "IsEncrypted": false,"Values": {
    "AzureWebJobsstorage": "UseDevelopmentStorage=true","FUNCTIONS_WORKER_RUNTIME": "dotnet"
  }
}

C尖代码如下:

using System;
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace Company.Function
{
    public static class BlobTriggerCSharp1
    {
        [FunctionName("BlobTriggerCSharp1")]
        public static void Run([BlobTrigger("samples-workitems/{name}",Connection = "AzureWebJobsstorage")]Stream myBlob,string name,ILogger log)
        {
            log.Loginformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
        }
    }
}

我正在尝试在容器上的 Microsoft File Azure 存储上创建新文件

local-emulator -> Blob Containers -> samples-workitems -> 创建一个新项目

所以当我跑了一段时间后,总是会出现以下错误功能

        BlobTriggerCSharp1: blobTrigger

For detailed output,run func with --verbose flag.
[2021-05-06T11:29:19.279Z] Host lock lease acquired by instance ID '000000000000000000000000182E0241'.   
[2021-05-06T11:29:47.002Z] An unhandled exception has occurred. Host is shutting down.
[2021-05-06T11:29:47.003Z] Microsoft.WindowsAzure.Storage: No connection Could be made because the target machine actively refused it. System.Net.Http: No connection Could be made because the target machine actively refused it. System.Private.CoreLib: No connection Could be made because the target machine actively refused it.

编辑

当我尝试从本地 Azure 函数使用 Azurite 访问本地存储帐户时

        var connection = new 

Uri("http://127.0.0.1:10000/devstoreaccount1/test123");

try {
            BlobContainerClient client = new BlobContainerClient(connection,new DefaultAzureCredential());

            await foreach (BlobItem blobItem in client.GetBlobsAsync())
            {
                Console.WriteLine("\t" + blobItem.Name);
            }

调用 client.GetBlobAsync 时出现错误

“不能在没有 HTTPS 的情况下使用 TokenCredential。”

EDIT2

我这样做的方法是按照本教程进行操作:https://blog.jongallant.com/2020/04/local-azure-storage-development-with-azurite-azuresdks-storage-explorer/

但我无法设置 Visual Studio Code 的 Azurite 扩展来使用它。我需要在单独的命令行中执行此操作,并且需要通过 https 执行此操作。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)