Azure Function 404 Error when running in Logic App












0















I have built a simple function in Azure that takes in the location of a file from the json body, and reads the first line to get the headers from said file. I am building the function in Visual Studio and publishing it using a packaged deployment.



I am able to test the function on the portal under Azure Functions and have a return result, but when I try and the function in Logic App's, I am getting 404 Not Found Error.



I have created the sample HTTPRequest Function that MS has given, and that works fine under the same Function Name, but I am not sure why the one I have written is not working.



Below is the code that I used for the function



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");
}
}
}
}


Here is the code that is working in the MS Sample Function:



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");
}
}
}


Here is the result of the code when I am running it in Azure Functions:
Azure FunctionResult from Azure Function



And here is the error that I am getting from Logic Apps once I try and run using the function:
Log App Error



Below is the logic app json (replacing subscription ID with xxxx)



{
"$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"
}
}
}
}









share|improve this question




















  • 1





    Could you share the logic app code (the json template) please ?

    – Thomas
    Jan 1 at 21:02











  • @Nirmie, have you tried modifying the working HttpFunction to meat your requirement ? try to go step by step and maybe you'll find something, Sorry dont really know whats hapenning here

    – Thomas
    Jan 2 at 9:47






  • 1





    @Thomas, I did what you said and that worked. Code is like for like and it now works fine using the HttpFunction rather than the one I wrote. I have no idea what has happened. Thanks!

    – Nirmie
    Jan 2 at 10:43











  • @Nirmie good to ear :-)

    – Thomas
    Jan 2 at 11:43
















0















I have built a simple function in Azure that takes in the location of a file from the json body, and reads the first line to get the headers from said file. I am building the function in Visual Studio and publishing it using a packaged deployment.



I am able to test the function on the portal under Azure Functions and have a return result, but when I try and the function in Logic App's, I am getting 404 Not Found Error.



I have created the sample HTTPRequest Function that MS has given, and that works fine under the same Function Name, but I am not sure why the one I have written is not working.



Below is the code that I used for the function



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");
}
}
}
}


Here is the code that is working in the MS Sample Function:



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");
}
}
}


Here is the result of the code when I am running it in Azure Functions:
Azure FunctionResult from Azure Function



And here is the error that I am getting from Logic Apps once I try and run using the function:
Log App Error



Below is the logic app json (replacing subscription ID with xxxx)



{
"$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"
}
}
}
}









share|improve this question




















  • 1





    Could you share the logic app code (the json template) please ?

    – Thomas
    Jan 1 at 21:02











  • @Nirmie, have you tried modifying the working HttpFunction to meat your requirement ? try to go step by step and maybe you'll find something, Sorry dont really know whats hapenning here

    – Thomas
    Jan 2 at 9:47






  • 1





    @Thomas, I did what you said and that worked. Code is like for like and it now works fine using the HttpFunction rather than the one I wrote. I have no idea what has happened. Thanks!

    – Nirmie
    Jan 2 at 10:43











  • @Nirmie good to ear :-)

    – Thomas
    Jan 2 at 11:43














0












0








0








I have built a simple function in Azure that takes in the location of a file from the json body, and reads the first line to get the headers from said file. I am building the function in Visual Studio and publishing it using a packaged deployment.



I am able to test the function on the portal under Azure Functions and have a return result, but when I try and the function in Logic App's, I am getting 404 Not Found Error.



I have created the sample HTTPRequest Function that MS has given, and that works fine under the same Function Name, but I am not sure why the one I have written is not working.



Below is the code that I used for the function



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");
}
}
}
}


Here is the code that is working in the MS Sample Function:



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");
}
}
}


Here is the result of the code when I am running it in Azure Functions:
Azure FunctionResult from Azure Function



And here is the error that I am getting from Logic Apps once I try and run using the function:
Log App Error



Below is the logic app json (replacing subscription ID with xxxx)



{
"$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"
}
}
}
}









share|improve this question
















I have built a simple function in Azure that takes in the location of a file from the json body, and reads the first line to get the headers from said file. I am building the function in Visual Studio and publishing it using a packaged deployment.



I am able to test the function on the portal under Azure Functions and have a return result, but when I try and the function in Logic App's, I am getting 404 Not Found Error.



I have created the sample HTTPRequest Function that MS has given, and that works fine under the same Function Name, but I am not sure why the one I have written is not working.



Below is the code that I used for the function



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");
}
}
}
}


Here is the code that is working in the MS Sample Function:



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");
}
}
}


Here is the result of the code when I am running it in Azure Functions:
Azure FunctionResult from Azure Function



And here is the error that I am getting from Logic Apps once I try and run using the function:
Log App Error



Below is the logic app json (replacing subscription ID with xxxx)



{
"$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"
}
}
}
}






c# azure azure-functions azure-logic-apps






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 8:19







Nirmie

















asked Jan 1 at 12:00









NirmieNirmie

82




82








  • 1





    Could you share the logic app code (the json template) please ?

    – Thomas
    Jan 1 at 21:02











  • @Nirmie, have you tried modifying the working HttpFunction to meat your requirement ? try to go step by step and maybe you'll find something, Sorry dont really know whats hapenning here

    – Thomas
    Jan 2 at 9:47






  • 1





    @Thomas, I did what you said and that worked. Code is like for like and it now works fine using the HttpFunction rather than the one I wrote. I have no idea what has happened. Thanks!

    – Nirmie
    Jan 2 at 10:43











  • @Nirmie good to ear :-)

    – Thomas
    Jan 2 at 11:43














  • 1





    Could you share the logic app code (the json template) please ?

    – Thomas
    Jan 1 at 21:02











  • @Nirmie, have you tried modifying the working HttpFunction to meat your requirement ? try to go step by step and maybe you'll find something, Sorry dont really know whats hapenning here

    – Thomas
    Jan 2 at 9:47






  • 1





    @Thomas, I did what you said and that worked. Code is like for like and it now works fine using the HttpFunction rather than the one I wrote. I have no idea what has happened. Thanks!

    – Nirmie
    Jan 2 at 10:43











  • @Nirmie good to ear :-)

    – Thomas
    Jan 2 at 11:43








1




1





Could you share the logic app code (the json template) please ?

– Thomas
Jan 1 at 21:02





Could you share the logic app code (the json template) please ?

– Thomas
Jan 1 at 21:02













@Nirmie, have you tried modifying the working HttpFunction to meat your requirement ? try to go step by step and maybe you'll find something, Sorry dont really know whats hapenning here

– Thomas
Jan 2 at 9:47





@Nirmie, have you tried modifying the working HttpFunction to meat your requirement ? try to go step by step and maybe you'll find something, Sorry dont really know whats hapenning here

– Thomas
Jan 2 at 9:47




1




1





@Thomas, I did what you said and that worked. Code is like for like and it now works fine using the HttpFunction rather than the one I wrote. I have no idea what has happened. Thanks!

– Nirmie
Jan 2 at 10:43





@Thomas, I did what you said and that worked. Code is like for like and it now works fine using the HttpFunction rather than the one I wrote. I have no idea what has happened. Thanks!

– Nirmie
Jan 2 at 10:43













@Nirmie good to ear :-)

– Thomas
Jan 2 at 11:43





@Nirmie good to ear :-)

– Thomas
Jan 2 at 11:43












1 Answer
1






active

oldest

votes


















0














The NotFound error happens either when the function app and logic app are located on a seperate location and the logicapp trigger is not able to execute the function. This happened to me alot of times. A simple solution is to deploy both of the resources in the same location and it should work.






share|improve this answer
























  • I am not sure I understand the comment here. Both my LogicApp and Function are in the same location (West Europe), under the same Resource Group. Also, I am not sure why it would work for the HTTPTrigger Function, but not for the custom one.

    – Nirmie
    Jan 2 at 8:32











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53995249%2fazure-function-404-error-when-running-in-logic-app%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














The NotFound error happens either when the function app and logic app are located on a seperate location and the logicapp trigger is not able to execute the function. This happened to me alot of times. A simple solution is to deploy both of the resources in the same location and it should work.






share|improve this answer
























  • I am not sure I understand the comment here. Both my LogicApp and Function are in the same location (West Europe), under the same Resource Group. Also, I am not sure why it would work for the HTTPTrigger Function, but not for the custom one.

    – Nirmie
    Jan 2 at 8:32
















0














The NotFound error happens either when the function app and logic app are located on a seperate location and the logicapp trigger is not able to execute the function. This happened to me alot of times. A simple solution is to deploy both of the resources in the same location and it should work.






share|improve this answer
























  • I am not sure I understand the comment here. Both my LogicApp and Function are in the same location (West Europe), under the same Resource Group. Also, I am not sure why it would work for the HTTPTrigger Function, but not for the custom one.

    – Nirmie
    Jan 2 at 8:32














0












0








0







The NotFound error happens either when the function app and logic app are located on a seperate location and the logicapp trigger is not able to execute the function. This happened to me alot of times. A simple solution is to deploy both of the resources in the same location and it should work.






share|improve this answer













The NotFound error happens either when the function app and logic app are located on a seperate location and the logicapp trigger is not able to execute the function. This happened to me alot of times. A simple solution is to deploy both of the resources in the same location and it should work.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 2 at 4:22









HariHaranHariHaran

571415




571415













  • I am not sure I understand the comment here. Both my LogicApp and Function are in the same location (West Europe), under the same Resource Group. Also, I am not sure why it would work for the HTTPTrigger Function, but not for the custom one.

    – Nirmie
    Jan 2 at 8:32



















  • I am not sure I understand the comment here. Both my LogicApp and Function are in the same location (West Europe), under the same Resource Group. Also, I am not sure why it would work for the HTTPTrigger Function, but not for the custom one.

    – Nirmie
    Jan 2 at 8:32

















I am not sure I understand the comment here. Both my LogicApp and Function are in the same location (West Europe), under the same Resource Group. Also, I am not sure why it would work for the HTTPTrigger Function, but not for the custom one.

– Nirmie
Jan 2 at 8:32





I am not sure I understand the comment here. Both my LogicApp and Function are in the same location (West Europe), under the same Resource Group. Also, I am not sure why it would work for the HTTPTrigger Function, but not for the custom one.

– Nirmie
Jan 2 at 8:32




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53995249%2fazure-function-404-error-when-running-in-logic-app%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

A Topological Invariant for $pi_3(U(n))$