- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我使用 Azure Http 触发器创建了一个开箱即用的 Azure Function App。这给了我下面的代码。我所更新的只是将 HttpRequest 主体转换为我的 Helper 类。
这是代码
public static class TriggerTest
{
[FunctionName("TriggerTest")]
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequest req, TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = new StreamReader(req.Body).ReadToEnd();
Helper data = JsonConvert.DeserializeObject<Helper>(requestBody);
name = name ?? data?.value;
return name != null
? (ActionResult)new OkObjectResult($"Hello, {name}")
: new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}
}
public class Helper
{
public string value { get; set; }
}
当我尝试运行它时,它可以正常编译,但随后控制台会收到以下垃圾邮件
A ScriptHost error has occured
System.Private.CoreLib: Exception while executing function: TriggerTest. TestingAzure.FunctionApp: Could not load file or assembly ‘Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’. Could not find or load a specific file (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly ‘Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’
所有 Nuget 包都引用 Newtonsoft 11.0.2,这也是 Microsoft.NET.Sdk.Functions 引用的内容。该项目是.NET Standard 2.0 项目。我引用的 Nuget 包是
我正在本地运行此程序,尚未在 Azure 中对其进行测试,但出于测试目的,我需要它在本地工作。
另外,从 Visual Studio 2017 下载的 CLI 是 2.0.1-beta.25
适用于 Visual Studio 的 Azure Functions 和 Web 作业工具版本为 15.10.2009.0
最佳答案
对于 v2 函数,Function sdk 1.0.19(>=1.0.14) 默认引用 Newtonsoft.Jon v11.0.2。该错误是由您的 VS 使用的 CLI 引起的。 2.0.1-beta.25太老了,VS中最新的是2.0.1-beta.38现在。
解决方案是确保下载成功。此外,Microsoft.Azure.WebJobs.ServiceBus
应该是 3.0.0-beta8
。
删除旧 CLI 文件夹 %localappdata%\AzureFunctionsTools
。
重新启动 VS 并创建新的 Azure 函数。在创建对话框中等待 VS 下载新的 CLI 和模板,直到我们看到提示更改为“更新已准备就绪”。
如果在一段时间后(您这边需要下载 200M 文件)没有看到更新已准备好,请再次检查 %localappdata%\AzureFunctionsTools
。如果只有文件夹 2.0.1-beta.25 充满了内容,请尝试重复上述步骤或诉诸 update part of this answer如需手动下载,需要访问%localappdata%\AzureFunctionsTools\feed.json
找到最新版本的下载地址(目前feed版本=2.5.2)。
关于c# - Newtonsoft 11.0.0.0 无法在 Azure Function App 2.0 上加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52221820/
如果我调用一个应用程序两次或多次,但只有一个实例应该运行(这是所需的),我就会遇到一个问题。 首先一些(可能必要的)背景信息: 使用 MAC OS X El Capitan (10.11.6) 我有一
覆盖文件。覆盖 Apps 脚本文件。 这是不是 创建一个新的 Apps 脚本文件的问题。那对我没有帮助。我需要更新 现有的 Apps 脚本文件。这个问题类似于创建一个新文件,但不是同一个问题。更新的语
我是 Apps 脚本的新手,正在尝试了解使用另一个帐户在一个帐户中运行/触发脚本的基础知识。需要注意的是:我想在访问脚本的用户而不是拥有脚本的用户的情况下运行脚本——以便将运行时间分配给访问的用户。
我是 Apps 脚本的新手,正在尝试了解使用另一个帐户在一个帐户中运行/触发脚本的基础知识。需要注意的是:我想在访问脚本的用户而不是拥有脚本的用户的情况下运行脚本——以便将运行时间分配给访问的用户。
我有一个安卓应用程序。我想为我的应用程序实现 App Indexing。 我已经点击了 Google 开发者链接 https://developers.google.com/app-indexing/
有什么区别: import App from '../components/App'; 和 var App = require('../components/App'); 两者都用于获取组件,但它没有
问题: 我有一个使用 requireJS 的简单演示应用程序。当require.min.js脚本加载时,它尝试加载入口点脚本。但是,问题是,而不是 localhost:8090/js/app.js它尝
我正在构建一个 React Native 应用程序,目前正在尝试通过 Firebase Auth 实现一个身份验证注册系统。我已经按照指南/网站上的文档来设置 Firebase 配置文件。我运行该应用
因此 app.yaml 文件的一部分如下所示(至少在 GAE 教程中): handlers: - url: /.* script: main.app 但是,我也看到它看起来像这样: handler
我是Android App开发的新手。当我尝试创建一个新项目Android Project时,弹出以下消息: Information:Gradle tasks [:app:generateDebugS
我正在编写一个应用程序脚本(用于处理电子邮件、任务和日历事件)并希望将其部署为网络应用程序。 该应用程序将在运行它的用户的上下文中运行。该应用程序将被超过 10k+ 的用户使用,甚至可能更多。 在将其
我需要实现一个用于登录网站的 Google Apps 脚本应用,然后如果该网站上的身份验证过程成功,用户应该会在 google 脚本边栏中收到一条消息。 例如:用户输入他的邮箱和密码,然后他点击登录按
我正在开发一个跨平台应用程序,它将在 Google Play 商店和 App Store 上发布。 Google Play 政策以及 App Store 政策规定,您不能使用其他支付系统购买将在应用程
我的 AppEngine 应用程序在我的台式机上的开发服务器上运行良好,但我无法在 Google 服务器上获取版本以关注我的源代码更新。 这是最有说服力的例证。我的 app.yaml 文件开始于: a
我像这样将所有内容重定向到我的 app.yaml 中的单个文件 - url: /.* script: frontcontroller.application 但我仍然必须使用 robots.txt
我想构建一个基于 App Engine 的网络应用程序,并使用 Google 帐户对用户进行身份验证。我需要来自多个域的用户可以登录。从我读到的内容看来,仅使用 Google Accounts API
我无法将我的域指向我使用 Google App Engine 托管的网站。这是背景……注意区分“google apps”(域托管、电子邮件等)和“google app engine”(网站框架)的概念
是否可以通过 App Engine 上内置的 OpenId 实现单点登录?我一直在尝试集成一个 Marketplace 应用程序,并让用户在来自 Google Apps(管理面板或通用导航)时登录。我
有没有办法从 azure-cli 为 Web 应用或函数应用创建和/或激活 App Insights? 现在浏览文档。 最佳答案 我之前也考虑过你的问题。要创建应用程序洞察力,az resource
我在以 Angular 创建新项目时遇到问题。当我运行 ng new myapp 命令时,我得到以下命令 ng 新问候语 Error: Path "/app/app.module.ts" does n
我是一名优秀的程序员,十分优秀!