Hello,
I am trying to connect to my D365(CE) instance from an Azure Function. I have tried the multiple options found on the internet but the XRM Tooling connection is failing.
Following are the details
D365 instance version: Server version: 9.1.0000.17446(2020 release wave 1 enabled)
D365 SDK :microsoft.crmsdk.xrmtooling.coreassembly.9.1.0.42
Azure Function Run time version: 1
Azure Function Trigger: HTTP C#
Code:
#r "Newtonsoft.Json"
#r "System.Configuration"
#r "Microsoft.IdentityModel.Clients.ActiveDirectory.dll"
#r "Microsoft.Xrm.Sdk.dll"
#r "Microsoft.Xrm.Tooling.Connector.dll"
using System.Net;
using System.Configuration;
using System.Security.Claims;
using System.Net.Http.Headers;
using Newtonsoft.Json;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System.Net;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Client;
using System.ServiceModel.Description;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Tooling.Connector;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
public static async Task Run(HttpRequestMessage req, TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
// parse query parameter
string name = req.GetQueryNameValuePairs()
.FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0)
.Value;
if (name == null)
{
// Get request body
dynamic data = await req.Content.ReadAsAsync();
name = data?.name;
}
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
CrmServiceClient client = new CrmServiceClient("AuthType=Office365;Username=**@***.onmicrosoft.com;Password=****;Url=https://****.crm4.dynamics.com");
if (client.LastCrmError != "" && client.LastCrmError != null)
{
throw new Exception(client.LastCrmError);
}
return name == null
? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body")
: req.CreateResponse(HttpStatusCode.OK, "Hello " name);
}
Error : Unable to connect to CRM: Method not found: 'Void Microsoft.Crm.Sdk.Messages.RetrieveCurrentOrganizationRequest.set_AccessType(Microsoft.Xrm.Sdk.Organization.EndpointAccessType)'. Method not found: 'Void Microsoft.Crm.Sdk.Messages.RetrieveCurrentOrganizationRequest.set_AccessType(Microsoft.Xrm.Sdk.Organization.EndpointAccessType)'.Unable to Login to Dynamics CRM Unable to Login to Dynamics CRM.

Has anyone tried this? Most of the articles I found on internet is connecting using old SDK which won't work for connecting to the latest instances.
PS: There are many unwanted libraries referred in the code, I believe that won't cause any issues at this stage.
Many thanks in advance.