Я пытаюсь подключиться к Dynamics 365 Online с помощью функций Azure. Я следовал учебному пособию в Интернете, но оно основано на функциях Azure 1.
Я получаю ошибку:
2018-11-03T05:21:00.621 [Information] Executing 'Functions.Test' (Reason='This function was programmatically called via the host APIs.', Id=c6ddb58b-51dc-4679-b985-4bcc7934c246)
2018-11-03T05:21:00.984 [Error] Executed 'Functions.Test' (Failed, Id=c6ddb58b-51dc-4679-b985-4bcc7934c246)
Could not load the specified file.
Мой код выглядит следующим образом:
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using System.ServiceModel;
using Microsoft.Xrm.Tooling.Connector;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
//using Newtonsoft.Json;
public static async Task<IActionResult> Run(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;
// log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
var connectionString = @"AuthType = Office365;
Url = https://*******.crm4.dynamics.com/;Username=******@*****;Password=****";
CrmServiceClient conn = new CrmServiceClient(connectionString);
IOrganizationService service;
service = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;
Entity lead = new Entity("lead");
lead.Attributes["subject"] = "New Lead: " + name ;
service.Create(lead);
return name != null
? (ActionResult)new OkObjectResult($"Hello, {name}")
: new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}
Мой functions.proj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CrmSdk.CoreAssemblies" Version="9.0.2.5"/>
<PackageReference Include="System.ServiceModel.Security" Version="4.5.3"/>
<PackageReference Include="Microsoft.CrmSdk.XrmTooling.CoreAssembly" Version="9.0.2.7"/>
</ItemGroup>
</Project>
Кто-нибудь знает, что я могу делать неправильно?