Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在门户中运行Azure函数时获取内部服务器错误_Azure_Azure Functions_Azure Functions Runtime_Azure Functions Core Tools - Fatal编程技术网

在门户中运行Azure函数时获取内部服务器错误

在门户中运行Azure函数时获取内部服务器错误,azure,azure-functions,azure-functions-runtime,azure-functions-core-tools,Azure,Azure Functions,Azure Functions Runtime,Azure Functions Core Tools,我已经从visual studio创建并发布了一个Http触发的Azure函数。该函数用于连接到iot集线器并获取模块twin属性 我已经用模块连接字符串配置了local.settings.json文件,并在门户的应用程序设置中添加了相同的内容。 但当我在门户中运行该函数时,它会给我内部服务器错误500 我正在运行的Azure函数版本是v1 我正在使用的json文件: local.settings.json host.json function.json 代码如下: 功能1.cs twin.cs

我已经从visual studio创建并发布了一个Http触发的Azure函数。该函数用于连接到iot集线器并获取模块twin属性

我已经用模块连接字符串配置了local.settings.json文件,并在门户的应用程序设置中添加了相同的内容。 但当我在门户中运行该函数时,它会给我内部服务器错误500

我正在运行的Azure函数版本是v1

我正在使用的json文件:

local.settings.json

host.json

function.json

代码如下:

功能1.cs

twin.cs

我已尝试将运行时版本从1更改为2,反之亦然。但它仍然不起作用。在应用程序设置下,我也设置了

网站\节点\默认\版本

从6.5.0改为8.11.1


有谁能帮我解决这个问题吗?

HTTP函数应该实际返回HTTP结果,请尝试将函数更改为

公共静态异步任务运行 [HttpTriggerAuthorizationLevel.Function,get,post,Route=null]HttpRequestMessage请求, 伊洛格测井 { //你的密码在这里 返回req.CreateResponseHttpStatusCode.OK,完成; }
函数App?@Mikhail的日志中有任何内容吗?在Monitor部分,log c HTTP trigger函数处理了一个请求,它具有日志级别的信息。之后,我得到了日志级错误。日期、消息和日志级别是我在调用详细信息中能找到的唯一信息。那么错误消息说什么呢?@Mikhail这是控制台的日志。2018-09-06T09:24:17欢迎光临,您现在已连接到日志流媒体服务。2018-09-06T09:24:31.605[信息]执行'Function1'原因='此函数是通过主机API以编程方式调用的',Id=4832F4B-325c-489b-92be-6d7427e9cb1b 2018-09-06T09:24:31.605[信息]C HTTP触发器函数处理了一个请求。2018-09-06T09:24:31.662[错误]执行的“功能1”失败,Id=4832F4B-325c-489b-92be-6D7427E9CB1B错误消息字段为空
{
      "IsEncrypted": false,
      "Values": {
        "AzureWebJobsStorage": "xxxxxxxx",
        "AzureWebJobsDashboard": "xxxxxx",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet",
        "ModuleConnectionString": "xxxxxxxxx"
      }
    }
{
  "http": {

"routePrefix": "api",

"maxOutstandingRequests": 20,

"maxConcurrentRequests": 10,

"dynamicThrottlesEnabled": false

    },

 "version": "2.0"

}
{
  "generatedBy": "Microsoft.NET.Sdk.Functions-1.0.19",
  "configurationSource": "attributes",
  "bindings": [
    {
      "type": "httpTrigger",
      "methods": [
        "get",
        "post"
      ],
      "authLevel": "function",
      "name": "req"
    }
  ],
  "disabled": false,
  "scriptFile": xxxx.dll",
  "entryPoint": "xxxxxxxx.Run"
}
    public static class Function1
    {
        [FunctionName("Function1")]
        public static async Task Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequest req, ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");


            var moduleConnectionString = Environment.GetEnvironmentVariable("ModuleConnectionString", EnvironmentVariableTarget.Process);


            ModuleClient _moduleClient = ModuleClient.CreateFromConnectionString(moduleConnectionString, TransportType.Amqp);

            var sample = new TwinSample(_moduleClient);
            await sample.RunSampleAsync();
       }
    }
class TwinSample
    {

        private ModuleClient _moduleClient;


        public TwinSample(ModuleClient moduleClient)
        {
            this._moduleClient = _moduleClient;
        }


        public async Task<string> RunSampleAsync()
        {
            Console.WriteLine("Retrieving twin...");
            Twin twin = await _moduleClient.GetTwinAsync().ConfigureAwait(false);

            Console.WriteLine("\tInitial twin value received:");

            Console.WriteLine($"\t{twin.ToJson()}");
            return twin.ToJson();
        }
    }