我在Azure中构建了一个简单的函数,该函数从json主体中获取文件的位置,并读取第一行以从该文件中获取头部。我正在Visual Studio中构建函数,并使用打包部署发布它。
我可以在Azure Functions下测试门户上的函数,并有一个返回结果,但当我尝试和逻辑应用程序的函数时,我得到了404未找到的错误。
我已经创建了MS给出的示例HTTPRequest函数,该函数在相同的函数名下运行良好,但我不确定为什么我编写的函数不能运行。
using System;
using System.IO;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
namespace Functions
{
public static class GetTableHeaders
{
[FunctionName("GetTableHeaders")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
IBinder binder,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string guid = req.Query["guid"];
string header = req.Query["header"];
string location = req.Query["location"];
string line = null;
string[] headers = null;
int size = 0;
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
guid = guid ?? data?.guid;
header = header ?? data?.header;
location = location ?? data?.location;
if (guid != null)
{
location = location.Substring(1);
using (var reader = binder.Bind<TextReader>(new BlobAttribute(
$"{location}", FileAccess.Read)))
{
line = reader.ReadLine();
headers = line.Split(',');
size = headers.Length;
if (!Convert.ToBoolean(header))
{
List<string> genericheaders = new List<string>();
for (int i = 1; i <= size; i++)
{
genericheaders.Add($"column{i}");
}
headers = genericheaders.ToArray();
}
};
return (ActionResult)new OkObjectResult($"{string.Join("|", headers)}");
}
else
{
return (ActionResult)new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}
}
}
}
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
namespace Functions
{
public static class HttpFunction
{
[FunctionName("HttpFunction")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;
return name != null
? (ActionResult)new OkObjectResult($"Hello, {name}")
: new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}
}
}
{
"$connections": {
"value": {
"azureblob": {
"connectionId": "/subscriptions/xxxx/resourceGroups/AMCDS/providers/Microsoft.Web/connections/azureblob",
"connectionName": "azureblob",
"id": "/subscriptions/xxxx/providers/Microsoft.Web/locations/westeurope/managedApis/azureblob"
},
"sql": {
"connectionId": "/subscriptions/xxxx/resourceGroups/AMCDS/providers/Microsoft.Web/connections/sql-1",
"connectionName": "sql-1",
"id": "/subscriptions/xxxx/providers/Microsoft.Web/locations/westeurope/managedApis/sql"
}
}
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Create_GUID": {
"inputs": "@guid()",
"runAfter": {},
"type": "Compose"
},
"GetTableHeaders": {
"inputs": {
"body": {
"guid": "@{outputs('Create_GUID')}",
"header": "@{body('Insert_row_2')?['HasHeaders']}",
"location": "@{triggerBody()?['Path']}"
},
"function": {
"id": "/subscriptions/xxxx/resourceGroups/AMCDS/providers/Microsoft.Web/sites/AMCDSFunctionsWindows/functions/GetTableHeaders"
},
"method": "POST"
},
"runAfter": {
"Insert_row_2": [
"Succeeded"
]
},
"type": "Function"
},
"HttpFunction": {
"inputs": {
"body": {
"name": "Nirmal"
},
"function": {
"id": "/subscriptions/xxxx/resourceGroups/AMCDS/providers/Microsoft.Web/sites/AMCDSFunctionsWindows/functions/HttpFunction"
}
},
"runAfter": {
"Insert_row_2": [
"Succeeded"
]
},
"type": "Function"
},
"Insert_row_2": {
"inputs": {
"body": {
"DataType": "@{outputs('Split_FileName')[3]}",
"DateLoaded": "@{utcNow()}",
"FileDate": "@{outputs('Split_FileName')[1]}",
"FileName": "@triggerBody()?['Name']",
"FilePath": "@triggerBody()?['Path']",
"GUID": "@{outputs('Create_GUID')}",
"HasHeaders": "@if(equals(outputs('Split_FileName')[2],'#Y#'),true,false)"
},
"host": {
"connection": {
"name": "@parameters('$connections')['sql']['connectionId']"
}
},
"method": "post",
"path": "/datasets/default/tables/@{encodeURIComponent(encodeURIComponent('[meta].[FileMetadata]'))}/items"
},
"runAfter": {
"Split_FileName": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Split_FileName": {
"inputs": "@split(triggerBody()?['Name'],'.')",
"runAfter": {
"Create_GUID": [
"Succeeded"
]
},
"type": "Compose"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"When_a_blob_is_added_or_modified_(properties_only)": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "get",
"path": "/datasets/default/triggers/batch/onupdatedfile",
"queries": {
"folderId": "JTJmcmVjZWl2ZWQ=",
"maxFileCount": 10
}
},
"metadata": {
"JTJmcmVjZWl2ZWQ=": "/received"
},
"recurrence": {
"frequency": "Minute",
"interval": 1
},
"splitOn": "@triggerBody()",
"type": "ApiConnection"
}
}
}
}
你已经清除了这个吗?
我也有同样的麻烦。它是通过使用逻辑应用程序JSON中的“方法”参数来修复的。
我的函数只接受“get”方法,而逻辑应用程序JSON没有方法参数,所以我添加了“'method':'get'”参数。
您好,我有一个关于逻辑应用程序和Azure服务总线队列的性能问题。 我有一个逻辑应用程序,看起来像这样: (注意:延迟是为了模拟一组连接器/操作,这些连接器/操作运行大约需要2秒钟,我还使用锁令牌和会话ID来完成消息和关闭会话) 它通过峰值锁定每秒轮询服务总线以获得高吞吐量,因为我的服务总线队列使用会话在流中启用FIFO排序。因此,我正在做的是,向我的服务总线发送大约2000条具有不同会话ID的消
在Azure Portal中的Azure函数中遇到了一个非常奇怪的问题。在我的例子中,Azure函数有一个输入,HTTPendpoint具有POST操作。显然,Azure函数在运行时失败,错误如下:
开始调试时,出现以下错误: 正在启动lib\main。调试模式下ONEPLUS A5000上的dart。。。lib\main。dart:1E/AndroidRuntime(11211):以书面形式命名,pkgName:com。刚出现的包裹azabazar E/AndroidRuntime(11211):致命异常:主E/AndroidRuntime(11211):进程:com。刚出现的包裹阿扎巴扎,
问题内容: 我安装了WebMatrix,并按照以下说明在Windows 7计算机上安装IIS 7。 当我单击“运行”以运行我的快速节点应用程序时,浏览器弹出并告诉我 iisnode模块无法启动node.exe进程。确保node.exe可执行文件在web.config 的system.webServer/iisnode/@nodeProcessCommandLine元素中指定的位置可用。默认情况下,
Adding application logic (添加应用程序逻辑) 构建一个应用时,通常需要实现自定义逻辑来处理数据,并响应客户端请求之前执行其他操作. 在 Loopback 中,可以通过以下三种方法实现. 添加 model 逻辑 - 使用 remote methods,remote hooks 和 operation hooks. 启动脚本 - 目录 /server/boot 中的文件,在应
除了上面的命令之外,我还尝试了 “sudo pm2 start npm--branch_env=stage node_env=production port=80 node appserverstart.js” 请救命! ----错误详细信息---- AppServerStart.js -----附加信息----服务器:CentOS Linux version 7 core,npm版本:6.4.1