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,...
Suggested Answer

Not able to connect to CRM from Azure Function

(0) ShareShare
ReportReport
Posted on by 30

Hi,

I have an azure function whose first step is to connect to CRM

following is my code:

public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "POST", Route = null)] HttpRequestMessage req, TraceWriter log)
{

IOrganizationService service = null;
string URL = "">https://xyz.crm.dynamics.com";
string userName = "cf_admin@xyz.com";
string password = "xyz";
// var res = Environment.GetEnvironmentVariable($"URL");

ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.UserName.UserName = userName;
clientCredentials.UserName.Password = password;
OrganizationServiceProxy organizationServiceProxy = new OrganizationServiceProxy(new Uri("" + URL + "/XRMServices/2011/Organization.svc"), null, clientCredentials, null);
//For Dynamics 365 Customer Engagement V9.X, set Security Protocol as TLS12
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
organizationServiceProxy.Timeout = new TimeSpan(0, 10, 0);
service = (IOrganizationService)organizationServiceProxy;

I published the function into azure portal, when I hit the azure function, but it is not connecting to CRM.

Locally this is working perfectly fine but when debugging the code from azure cloud service it does not connects to CRM.

It is giving the following error:

pastedimage1606819567626v1.jpeg

Any help is appreciated.

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Check my post on usage of CrmServiceClient - butenko.pro/.../

    You have to prepare the connection string and use CrmServiceClient from the latest SDK package.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 209 Super User 2026 Season 1

#2
CU11031447-0 Profile Picture

CU11031447-0 100

#3
NeerajPawar Profile Picture

NeerajPawar 71

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans