Skip to content

Instantly share code, notes, and snippets.

@StefH
Last active September 10, 2019 17:21
Show Gist options
  • Save StefH/35cff3503abf0838774329e894607dd4 to your computer and use it in GitHub Desktop.
Save StefH/35cff3503abf0838774329e894607dd4 to your computer and use it in GitHub Desktop.
AzureFunctionExecuteFunction.cs
[FunctionName("ExecuteSmartContractFunction")]
public async Task<IActionResult> RunExecuteFunctionAsync(
[HttpTrigger(AuthorizationLevel.Function, "post")]HttpRequest req)
{
_logger.LogInformation("ExecuteSmartContractFunction");
string body = await req.ReadAsStringAsync();
var request = JsonConvert.DeserializeObject<SmartContractFunctionRequest>(body);
try
{
var result = await _service.ExecuteFunctionAsync(request);
return new JsonResult(result, JsonSerializerSettings);
}
catch (Exception exception)
{
_logger.LogError(exception, "ExecuteSmartContractFunction failed");
return new JsonResult(new { exception.Message }, JsonSerializerSettings);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment