Reputation: 1742
Does anyone know if there's a simple, recommended way to always background start/stop Azurite using a temp directory when F5 debugging in VS Code, like Visual Studio proper does, maybe through the launch.json? I have the Azurite installed, so I can manually start the service and it works, but I find all of the __*__
files in my project directory to be really annoying. Not to mention the Azurite: Clean
command never cleans everything due to file-level locks. My environment is up to date and currently as follows:
Upvotes: 0
Views: 657
Reputation: 882
This is not exactly what you asked for but if I can provide an alternative you might find acceptable, you can hide all those files from the sidebar in VSCode by updating your local settings.
.vscode/settings.json
{
"files.exclude": {
"__azurite_db*__.json": true,
"__blobstorage__": true,
"__queuestorage__": true
}
}
Upvotes: 0
Reputation: 1742
This has been annoying me for years and I finally found an answer after digging into the Azure Functions issue log and finding Issue 3876. Until something is done to resolve this, the simple fix is to replace
{
//...
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=True"
// ...
}
}
with this
{
//...
"Values": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10010/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10011/devstoreaccount1;TableEndpoint=http://127.0.0.1:10012/devstoreaccount1;"
// ...
}
}
Upvotes: 0
Reputation: 8694
I have followed below steps to create a .NET8 Isolated Blob Trigger Azure function and able to run the function without running the Azurite manually, also could avoid creating extra(__*__)
files.
Azure Functions: Create Function
.Use Azurite Emulator for local storage
.The function gets created successfully.
local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
}
}
Output:
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'.
Folder Structure:
Upvotes: 0