在不启动模拟器的情况下调试 Visual Studio 中的 Azure 函数

Debug Azure functions in Visual Studio without starting the emulator

我有一个 Azure 函数项目,我通常 运行 通过调用 func.exe。 docker-compose 有蓝铜矿。

有时我需要在 visual studio 中逐步调试,所以我 Ctrl+C cli 运行 时间并在 visual studio 中点击 F5。但是,然后我必须 docker-compose stop azurite 因为 Visual Studio 想在它启动 func.exe 之前启动存储模拟器。有什么方法可以让 Visual Studio 不启动函数模拟器吗?

我认为你对 Azurite 和 Visual Studio 的使用产生了误解。

  1. 为什么要使用存储模拟器

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. 如何使用Azurite?参考这个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

然后就像使用Azure存储帐户一样使用它,修改连接字符串。从存储资源管理器获取 ConnectionString。

通知:

运行 来自 VS 的函数。 如果您遇到以下问题,请

然后你就可以运行成功了:

您可以将以下内容添加到您的 csproj 文件中:

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

微软推荐here