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

Notifications

Announcements

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

Responsible AI policies

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

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 57 Super User 2025 Season 2

#2
Satyam Prakash Profile Picture

Satyam Prakash 24

#2
Eugen Podkorytov Profile Picture

Eugen Podkorytov 24

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans