web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Authentication to Dynamics 365 using Azure Function v3 (.NET core)

(0) ShareShare
ReportReport
Posted on by 35

ex Message = "Failed to connect to Common Data Service",

StackTrace = " at Microsoft.PowerPlatform.Cds.Client.CdsServiceClient.CreateCdsServiceConnection(Object externalOrgServiceProxy, AuthenticationType requestedAuthType, String hostName, String port, String orgName, NetworkCredential credential, String userId, SecureString password, String domain, String Geo, String claimsHomeRealm, Boolean useSsl, Boolean useUniqueInstance, OrganizationDetail orgDetail, String clientId, Uri redirectUri, PromptBehavior promptBehavior, OrganizationWebProxyClient externalOrgWebProxyClient, String certificateThumbPrint, StoreName certificateStoreName, X509Certificate2 certificate, Uri instanceUrl, Boolean isCloned, Boolean useDefaultCreds, Version incomingOrgVersion)\r\n at Microsoft.PowerPlatform.Cds.Client.CdsServiceClient.ConnectToCdsService(String cdsConnectionString)\r\n at Microsoft.PowerPlatform.Cds.Client.CdsServiceClient..ctor(String cdsConnectionString)\r\n at AuzreCore.Function1.Run(HttpRequest req, ILogger log) in C:\\Users\\Mounika\\source\\repos\\AuzreCore\\AuzreCore\\Function1.cs:line 42"

Referred following blog

https://powerobjects.com/dynamics-365/authentication-to-dynamics-365-using-azure-function-v3-net-core/

This is my code

[FunctionName("Function1")]
public static void Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
try
{
var clientId = "d80fab83-4dea-483d-b980-c4b79600da7a";
var clientSecret = "lQ6G9E-SYZ~ZE3c.0c.qTrkLMF_E_6.HdZ";
var organizationUrl = "https://crm365.api.crm8.dynamics.com";
string connectionString = "Url=" + organizationUrl + "; " +
"AuthType=ClientSecret; " +
"ClientId= " + clientId + "; " +
"ClientSecret=" + clientSecret + "; " +
"RequireNewInstance=false; " +
"SkipDiscovery=true";
CdsServiceClient dataVerseConnection = new CdsServiceClient(connectionString);
if (!dataVerseConnection.IsReady)
{
throw new Exception("Authentication Failed!");
}
}
catch (Exception ex)
{
throw ex;
}

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    Please try to replace `organizationUrl` with `https://<organization-name>.crm.dynamics.com`, please refer to this official documentation:

    https://docs.microsoft.com/en-us/powerapps/developer/data-platform/xrm-tooling/use-connection-strings-xrm-tooling-connect#connection-string-parameters

    pastedimage1627609762020v1.jpeg

    In addition, I did not see the `SkipDiscovery` parameter in the document, please test it against the document.

    If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.

    Best Regards,

    Frank Gong

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 96 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans