Sea*_*ude 8 azure-functions azure-storage-explorer azurite
我已按照说明下载并安装适用于 Linux (Ubuntu 18.04) 的 Azurite。我想将其与 Azure 存储资源管理器(也已下载并安装)一起使用,以通过 BlobTrigger 直观地管理/测试 Azure Function。我了解如何启动 Azurite,并可以使用 Storage Exporer 将 blob 上传到模拟器容器。
无法弄清楚:
如何将 Azure Function 连接到 Azurite 容器以用作 Functions内部存储。
A。我"AzureWebJobsStorage": "UseDevelopmentStorage=true"在 中使用过local.settings.json,但我不知道如何将函数连接到 Azurite 中的给定容器
如何将函数连接到 Azurite 容器以实现BlobTrigger功能。
A。我需要添加"BlobTrigger": "<azuriteContainerConnectionString>"设置吗local.settings.json?
基本上,local.settings.json 中的值用于保存环境变量。
连接字符串在 function.json 中声明。如果你使用的是C#或者Java(需要编译的语言,而不是直接运行的语言),那么它总是有一个声明部分,编译后声明部分将转换为function.json。
我在本地启动 Azurite,并尝试使用默认存储帐户:
我得到了blob服务的默认连接字符串:
DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;
Run Code Online (Sandbox Code Playgroud)
我使用 blobtrigger 创建一个 C# azure 函数:
本地.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=0730bowmanwindow;AccountKey=xxxxxx==;EndpointSuffix=core.windows.net",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"str": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;"
}
}
Run Code Online (Sandbox Code Playgroud)
函数1.cs
using System;
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace FunctionApp1
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([BlobTrigger("test/{name}", Connection = "str")]Stream myBlob, string name, ILogger log)
{
log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
}
}
}
Run Code Online (Sandbox Code Playgroud)
看起来效果很好:
我设置AzureWebJobsStorage为azure上的存储,因为使用了10000端口。
这是文档:
https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?toc=/azure/storage/blobs/toc.json
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8014 次 |
| 最近记录: |