有没有办法为已编译的 Azure Functions 自动生成文件夹结构和 function.json 文件?
Is there a way to automatically generate the folder structure and function.json files for compiled Azure Functions?
如果我使用 Visual Studio (2017 15.3 preview with Azure Functions Tools for Visual Studio installed) 将以下函数发布到 Azure,它会自动生成 function.json
文件并将其放在代表函数名称的文件夹中.我假设它通过检查方法和参数的属性来做到这一点。
[FunctionName("EmailNotifications")]
public static async Task Run([ServiceBusTrigger(Topics.Enquiries, "EmailNotifications", AccessRights.Listen, Connection = "MyConnectionString")] Enquiry enquiry, TraceWriter log)
{
}
我想在构建时自己生成这些文件,以便可以将它们打包以便通过我们的常规部署管道进行部署。有办法吗?
我希望 Visual Studio 作为发布过程的一部分在幕后使用的任何东西都暴露在某个地方,但我找不到这些信息。
没错,有一个 post-build 工具可以检查属性并生成 function.json;但这是有问题的。
当前路径应该已经在构建时生成它们,因此您可以将它们包含在部署中。在项目的输出目录中搜索 function.json.
这不是发生在你身上吗?
FWIW,我们实际上希望消除从属性生成 function.json 的需要(参见 https://github.com/Azure/azure-webjobs-sdk-script/issues/1508 )并让函数直接加载 dll 并直接使用属性。
请注意,您不需要在构建计算机上安装 Azure Functions Tools。 function.json 文件是从 NuGet 包生成的 Microsoft.NET.Sdk.Functions. As long as you have a Visual Studio 2017 msbuild on your build machine, a regular build will produce the right files. If using VSTS, use the VS 2017 build agent. See Deploying Visual Studio 2017 Function Projects with VSTS 以获取更多信息。
如果我使用 Visual Studio (2017 15.3 preview with Azure Functions Tools for Visual Studio installed) 将以下函数发布到 Azure,它会自动生成 function.json
文件并将其放在代表函数名称的文件夹中.我假设它通过检查方法和参数的属性来做到这一点。
[FunctionName("EmailNotifications")]
public static async Task Run([ServiceBusTrigger(Topics.Enquiries, "EmailNotifications", AccessRights.Listen, Connection = "MyConnectionString")] Enquiry enquiry, TraceWriter log)
{
}
我想在构建时自己生成这些文件,以便可以将它们打包以便通过我们的常规部署管道进行部署。有办法吗?
我希望 Visual Studio 作为发布过程的一部分在幕后使用的任何东西都暴露在某个地方,但我找不到这些信息。
没错,有一个 post-build 工具可以检查属性并生成 function.json;但这是有问题的。
当前路径应该已经在构建时生成它们,因此您可以将它们包含在部署中。在项目的输出目录中搜索 function.json.
这不是发生在你身上吗?
FWIW,我们实际上希望消除从属性生成 function.json 的需要(参见 https://github.com/Azure/azure-webjobs-sdk-script/issues/1508 )并让函数直接加载 dll 并直接使用属性。
请注意,您不需要在构建计算机上安装 Azure Functions Tools。 function.json 文件是从 NuGet 包生成的 Microsoft.NET.Sdk.Functions. As long as you have a Visual Studio 2017 msbuild on your build machine, a regular build will produce the right files. If using VSTS, use the VS 2017 build agent. See Deploying Visual Studio 2017 Function Projects with VSTS 以获取更多信息。