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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Can connect with local function but Azure function fails

(0) ShareShare
ReportReport
Posted on by 5

The issue is repeatable and have found no workaround. Seems others are having similar problem:

I can connect to Dynamics365 with a correct connection string, can debug the Azure function locally and everything works fine. See snippet below:

try
{
  ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
  _myTI = new CultureInfo("en-US", false).TextInfo;
  _svc = new CrmServiceClient(connectionString);
  WhoAmIRequest request = new WhoAmIRequest();
  WhoAmIResponse response = (WhoAmIResponse)_svc.Execute(request);
  Console.WriteLine("Your UserId is {0}", response.UserId);
  exMessage = null;
}
catch (Exception ex)
{
  Console.WriteLine(ex.Message);
  exMessage = ex.Message   " | "   ex.StackTrace;
}

Please, note that I can test/debug this Azure function locally via Postman.

If I deploy the same function on Azure however, the connection fails. Everything is the same and the connection string is correct. This is the error: "ERROR REQUESTING Token FROM THE Authentication context" and this is the exception: "System.Exception: Unable to Login to Dynamics CRM". I am unable to understand what could cause the difference as the same code connection string works in local.

I have been chasing this issue for a while now (checked all the Xrm.tool and Xrm.Core dependencies etc.) to no avail. Any help would be much appreciated.

  • stolto Profile Picture
    5 on at

    -

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 109 Super User 2026 Season 2

#2
Syed Aqib Raza Profile Picture

Syed Aqib Raza 88

#3
ParthPatel249 Profile Picture

ParthPatel249 84

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans