
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
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;
}
Hi,
Please try to replace `organizationUrl` with `https://<organization-name>.crm.dynamics.com`, please refer to this official documentation:
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