skip to Main Content

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:

  • OS: Windows 11 23H2 (OS Build 22631.3527)
  • VS Code: 1.89.1 (w/ Azure, Azure Functions and Azurite extensions)
  • Azure Function Core Tools: 4.0.5700
  • Model: dotnet-isolated
  • Language: C#
  • local.settings.json contains "AzureWebJobsStorage": "UseDevelopmentStorage=true"

2

Answers


  1. Chosen as BEST ANSWER

    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;"
        // ...    
      }
    }
    

  2. 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.

    • Open Command Palette in Visual Studio Code(Ctrl+shift+p), select Azure Functions: Create Function.

    enter image description here

    • Select the Project folder, runtime and the function trigger.

    enter image description here

    • Select Use Azurite Emulator for local storage.

    enter image description here

    The function gets created successfully.

    local.settings.json:

    {
      "IsEncrypted": false,
      "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
      }
    }
    
    • Start debugging the function, this will run successfully without creating any extra files in the project folder.

    Output:

    Executing task: C:Program Filesdotnetdotnet.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:UsersunameSourceReposfunctionapp2binDebugnet8.0functionapp2.dll
      Determining projects to restore...
      Restored C:UsersunameAppDataLocalTempdba1mmm5.sngWorkerExtensions.csproj (in 1.66 sec).
      WorkerExtensions -> C:UsersunameAppDataLocalTempdba1mmm5.sngbuildoutMicrosoft.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:UsersunameSourceReposfunctionapp2functionapp2.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'. 
    

    enter image description here

    Folder Structure:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search