简体   繁体   English

我可以在Azure Functions 2.0中同时使用dotnet和node吗?

[英]Can I use both dotnet and node in Azure Functions 2.0?

由于耐用函数JS API现已受到限制,我想知道我是否可以使用C#脚本编写业务流程代码,并使用Azure Functions 2.0中的节点编写活动函数?

We're about to publish a v2 Functions release that removes the ability to run multiple languages in a single Function app. 我们将要发布v2 Functions版本,该版本将删除在单个Function应用程序中运行多种语言的功能。 Going forward, all functions within a Function app must be written in the same language. 展望未来,Function应用程序中的所有功能必须使用相同的语言编写。 (Note that v1 Function apps will not be affected by this.) (请注意,v1 Function应用程序将不受此影响。)

We're aiming to announce General Availability of Durable Functions JS later this year, which will include the rest of the API. 我们的目标是在今年晚些时候宣布持久功能JS的一般可用性,其中将包括API的其余部分。 The workaround we recommend at present is similar to what's documented here. 我们目前建议的解决方法与此处记录的类似 In your case, you could expose some JavaScript APIs over HTTP and have C# activity functions invoke them from the Function app that contains your C# orchestrator. 就您而言,您可以通过HTTP公开一些JavaScript API,并让C#活动函数从包含C#编排器的Function应用程序中调用它们。

Update 更新

New release has published, function app requires single language right now. 新版本已经发布,功能应用现在需要一种语言。 So this method is no longer valid. 因此,此方法不再有效。


You probably are talking about this limit as in JS some C# API is not implemented yet and some won't be implemented. 您可能正在谈论此限制,因为在JS中,某些C#API尚未实现,而某些将无法实现。

We can call JS Activity in C# orchestration function. 我们可以在C#编排函数中调用JS Activity。 Just test with a simple activity returns string, works as expected. 只需测试一个简单的活动即可返回字符串,按预期工作。

For local development, FUNCTIONS_WORKER_RUNTIME (in local.settings.json) specifies our function app language worker, only functions corresponding to this runtime can be recognized by function host. 对于本地开发, FUNCTIONS_WORKER_RUNTIME (在local.settings.json中)指定我们的函数应用语言工作者,函数宿主只能识别与此运行时对应的函数。 For example, in dotnet runtime, js functions are ignored. 例如,在dotnet运行时中,js函数将被忽略。

  1. Delete FUNCTIONS_WORKER_RUNTIME and the host is able to work with different languages. 删除FUNCTIONS_WORKER_RUNTIME ,主机将可以使用其他语言。

  2. Add one folder named after your Activity function to function app folder, containing function.json and index.js. 将一个以您的Activity函数命名的文件夹添加到function app文件夹中,其中包含function.json和index.js。 See illustration below(In VSCode, similar to VS ). 请参见下图(在VSCode中,类似于VS )。

    VSCode插图

  3. Add CopyToOutputDirectory action to functionappname.csproj. 将CopyToOutputDirectory操作添加到functionappname.csproj。

     <ItemGroup> ... <None Update="MyJsActivity\\index.js"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> <None Update="MyJsActivity\\function.json"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> </ItemGroup> 
  4. Feel free to install node module if needed, remember to add CopyToOutputDirectory action for package.json, so that we can install modules using it during deployment. 如果需要,可以随意安装节点模块,请记住为package.json添加CopyToOutputDirectory操作,以便我们可以在部署期间使用它来安装模块。

Besides on portal there's no such equivalent setting right now, host offers different language workers by default. 除了在门户网站上目前没有这样的等效设置之外,默认情况下,主机还提供其他语言工作者。 After deployment, everything should work. 部署后,一切都会正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Azure Functions 中使用 NuGet 包? - How can I use NuGet packages in my Azure Functions? dotnet core 2.0 mq,有什么用? - dotnet core 2.0 mq, what to use? 我是否可以创建一个Azure Webjob,它将功能公开给仪表板但不使用Azure存储? - Can I create an Azure Webjob that exposes functions to the dashboard but doesn't use Azure Storage? 我可以使用 dotnet publish 命令来构建 .NET Framework 应用程序吗? - Can I use dotnet publish command to build .NET Framework applications? 我可以在没有实体框架的情况下使用 graphql-dotnet 吗? - Can I use graphql-dotnet without Entity Framework? 为什么我不能在 C# 中将“dotnet run”与 xUnit 一起使用? - Why can't I use 'dotnet run' with xUnit in C#? 我可以在Azure函数上下载ODBC驱动程序吗? - Can I download ODBC drivers on Azure functions? 我如何使用Azure TableClient 2.0 BeginExecuteQuerySegmented - How do I use Azure TableClient 2.0 BeginExecuteQuerySegmented 我可以在代码中运行Azure函数吗? - Can i run Azure Functions in code? 如何使用Azure函数或逻辑应用程序将数据保存到sql数据库中? - How can I use Azure functions or logic apps to save data into sql database?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM