Debug Azure functions in Visual Studio without starting the emulator

Viewed 738

I have an Azure functions project that I normally run through calling func.exe. The docker-compose has azurite.

Sometimes I need to step through debug in visual studio so I Ctrl+C the cli runtime and hit F5 in visual studio. However, then I have to docker-compose stop azurite because Visual Studio wants to start up storage emulator before it starts up func.exe. Is there any way I can make Visual Studio not start up the function emulator?

2 Answers

You can add the following to your csproj file:

<PropertyGroup>
 <StartDevelopmentStorage>false</StartDevelopmentStorage>
</PropertyGroup>

As recommended by Microsoft here

I think you got misunderstanding of using Azurite with Visual Studio.

  1. Why use storage emulator?

Because an Azure Function requires a storage account, one is assigned or created when you publish your project to Azure. An HTTP trigger doesn't use an Azure Storage account connection string; all other trigger types require a valid Azure Storage account connection string.

  1. How to use Azurite? Refer to this tutorial.

(1) Install the latest version of Python

(2) Install Azure Storage Explorer

(3) Install and run Azurite:

# Install Azurite
npm install -g azurite

# Create an Azurite directory
mkdir c:/azurite

# Launch Azurite locally
azurite --silent --location c:\azurite --debug c:\azurite\debug.log

Then use it just like how you use Azure Storage Account, modify the connection string. Get the ConnectionString from Storage Explorer.

Notice:

Run your Function from VS. If you got the issue below, please modify the IP of your storage emulator

enter image description here

Then you could run it successfully:

enter image description here

Related