有谁知道在 VS Code 中进行 F5 调试时,是否有一种简单、推荐的方法始终使用临时目录在后台启动/停止 Azurite,就像 Visual Studio 本身所做的那样,也许通过 launch.json?我安装了 Azurite,因此我可以手动启动该服务并且它可以工作,但我发现项目目录中的所有
__*__
文件真的很烦人。更不用说 Azurite: Clean
命令 never 由于文件级锁定而清除所有内容。我的环境是最新的,目前如下:
我已按照以下步骤创建了 .NET8 隔离 Blob 触发器 Azure 函数,并且能够在不手动运行 Azurite 的情况下运行该函数,还可以避免创建额外的
(__*__)
文件。
Azure Functions: Create Function
。Use Azurite Emulator for local storage
。函数创建成功。
local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
}
}
输出:
Executing task: C:\Program Files\dotnet\dotnet.exe build /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary
MSBuild version 17.9.8+b34f75857 for .NET
Determining projects to restore...
All projects are up-to-date for restore.
functionapp2 -> C:\Users\uname\Source\Repos\functionapp2\bin\Debug\net8.0\functionapp2.dll
Determining projects to restore...
Restored C:\Users\uname\AppData\Local\Temp\dba1mmm5.sng\WorkerExtensions.csproj (in 1.66 sec).
WorkerExtensions -> C:\Users\uname\AppData\Local\Temp\dba1mmm5.sng\buildout\Microsoft.Azure.Fu
nctions.Worker.Extensions.dll
* Terminal will be reused by tasks, press any key to close it.
* Executing task: func host start
Azure Functions Core Tools
Core Tools Version: 4.0.5700 Commit hash: N/A +71cc84964a60bfb07d95839b7c666bd239507bdd (64-bit)
Function Runtime Version: 4.33.2.22572
[2024-05-14T12:16:01.703Z] Found C:\Users\uname\Source\Repos\functionapp2\functionapp2.csproj. Using fing for user secrets file configuration.
[2024-05-14T12:16:19.544Z] Worker process started and initialized.
Functions:
BlobTrigger1: blobTrigger
For detailed output, run func with --verbose flag.
[2024-05-14T12:16:22.956Z] Executing 'Functions.BlobTrigger1' (Reason='New blob detected(LogsAndContainerScan): samples-workitems/Helloworld.txt', Id=f6aa2108-0112-4cc1-9faf-3bc8b892171d)
[2024-05-14T12:16:22.967Z] Trigger Details: MessageId: 48c33c25-80dc-40b6-977b-75ccee932de9, DequeueCount: 1, InsertedOn: 2024-05-14T12:16:22.000+00:00, BlobCreated: 2024-05-14T11:56:05.000+00:00, BlobLastModified: 2024-05-14T11:56:05.000+00:00
[2024-05-14T12:16:23.708Z] C# Blob trigger function Processed blob
Name: Helloworld.txt
Data:
[2024-05-14T12:16:23.796Z] Executed 'Functions.BlobTrigger1' (Succeeded, Id=f6aa2108-0112-4cc1-9faf-3bc8b892171d, Duration=975ms)
[2024-05-14T12:16:24.440Z] Host lock lease acquired by instance ID '000000000000000000000000F72731CC'.
文件夹结构: