Добавлены следующие пакеты nuget
Код: Выделить всё
net8.0
v4
Exe
enable
enable
Код: Выделить всё
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;
using System.Net;
namespace CTSCRMIntegration
{
public class FuncIntegrationDemo
{
private readonly ILogger _logger;
private readonly ICMHCCRM _crm;
public FuncIntegrationDemo(ICMHCCRM crm, ILogger logger)
{
_crm = crm;
_logger = logger;
}
[Function("FuncIntegrationDemo")]
public async Task Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req)
{
string logMessage = string.Empty;
_logger.LogInformation("C# HTTP trigger function processed a request.");
//Parse SourceViewName Parameter
var SourceViewName = req.Query.GetValues("sourceViewName")?.FirstOrDefault();
if (string.IsNullOrEmpty(SourceViewName))
{
logMessage = "Please pass a Source view name on the query string";
_logger.LogInformation(logMessage);
var reqResponse = req.CreateResponse(HttpStatusCode.BadRequest);
await reqResponse.WriteStringAsync("Please pass a Source view name on the query string");
return reqResponse;
}
//Check for record exists in CRM
await _crm.MethodThrowingException(SourceViewName);
var response = req.CreateResponse(HttpStatusCode.OK);
await response.WriteStringAsync($"The record successfully synched with CRM !!!");
return response;
}
}
}
Код: Выделить всё
public class CMHCCRM : ICMHCCRM
{
private readonly CRMWebAPIFactory _webApiFactory;
public async Task MethodThrowingException(string sourceViewName)
{
throw new NotImplementedException("The method is not implemented to check the invocation list for blank error message");
}
}
Код: Выделить всё
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
var host = new HostBuilder()
.ConfigureFunctionsWebApplication().
ConfigureAppConfiguration(app => {
app.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables();
})
.ConfigureServices((context, services) => {
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
services.Configure(options => {
LoggerFilterRule defaultRule = options.Rules.FirstOrDefault(rule => rule.ProviderName
== "Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider");
if (defaultRule is not null)
{
options.Rules.Remove(defaultRule);
}
});
services.AddScoped(x => new CMHCCRM());
}).Build();
host.Run()
Код: Выделить всё
{
"version": "2.0"
}

Но если мы запустим запрос к таблице исключений, появится сообщение об исключении в поле externalMessage

Подробнее здесь: https://stackoverflow.com/questions/792 ... n-invocati
Мобильная версия