Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Unanswered

Can connect with local function but Azure function fails

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
    stolto 5 on at
    RE: Can connect with local function but Azure function fails

    -

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans