Error: "message": "Exception while executing function: Function1 -> Metadata contains a reference that cannot be resolved: 'crm.xyz.com/.../Organization.svc. -> Unable to connect to the remote server -> An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.5:443
Things performed till now
- After lot of research I was successful to make hybrid connection from Azure cloud to OnPrem CRM Server (with correct port name and port address
- This is showing as connected both on server and on Azure
- To simply test I did telnet on CMD (kunudu) and I was successful
- I wrote few lines of code to have orgservice with username and password. This was successful.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; IServiceManagement orgServiceManagement = ServiceConfigurationFactory.CreateManagement( new Uri("https://crm.xyz.com/Dev/XRMServices/2011/Organization.svc")); AuthenticationCredentials authCredentials = new AuthenticationCredentials(); authCredentials.ClientCredentials.UserName.UserName = "xyz\\admin"; authCredentials.ClientCredentials.UserName.Password = "1234pwd"; AuthenticationCredentials tokenCredentials = orgServiceManagement.Authenticate(authCredentials); OrganizationServiceProxy organizationServiceProxy = new OrganizationServiceProxy(orgServiceManagement, tokenCredentials.SecurityTokenResponse); organizationServiceProxy.EnableProxyTypes(); IOrganizationService newCrmService = (IOrganizationService)organizationServiceProxy; Guid userGuid = ((WhoAmIResponse)newCrmService.Execute(new WhoAmIRequest())).UserId; log.Info($"Guid of logged user with orgServiceManagement {userGuid}");
When I run this code locally, i could communicate with CRM and can perform operations.
But when I run the same code on azure it gives me below error
"message": "Exception while executing function: Function1 -> Metadata contains a reference that cannot be resolved: 'crm.xyz.com/.../Organization.svc. -> Unable to connect to the remote server -> An attempt was made to access a socket in a way forbidden by its access permissions 127.0.0.5:443
I looked into Google and found some articles which takes me closer
- links says using line ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; will solve the issue.
- Above line did not helped.
- Also I am using Azure function Version 1, reason I am referencing Dynamics 8.2 sdk and this is possible only in Azure function V1 as it is based on .net framework.
- Azure function version 2 is based on .net core and hence we cannot ref dynamics assembly.
- Articles like these and many more
says adding project.json file helped. I did that but did not worked for me.
What I think could be issue with me are below
- As it is onPrem and IFD facing, I need VPN to use CRM, maybe this is an issue?
- There is Pub certificate against CRM which we use. This certificate has been already added to Azure function with ssl/tls. Maybe this is an issue?
- Maybe somewhere in code and assembly dependencies for azure function I am missing?
Does anyone have any leads for the issue