Because the old connect to CRM Online is deprecated, we have to use the new method for CRM 2017 Online. The following procedure runs well at the local development system, but not at the target area, which is a Azure Web App:
CrmConnectionString = "AuthType=Office365; Url=https://<Org>.api.crm4.dynamics.com; Username=<User>; Password=<PW>;"
CrmServiceClient conn = new CrmServiceClient(CrmConnectionString);
Also tried:
CrmServiceClient conn =
new CrmServiceClient(
"<User>",
CrmServiceClient.MakeSecureString("<PW>"),
string.Empty,
"<Org>",
useUniqueInstance: false, useSsl: true, isOffice365: true);
Based on https://community.dynamics.com/crm/f/117/t/188785 also added to web.config:
<system.net>
<defaultProxy useDefaultCredentials="true"/>
</system.net>
Also try from https://blog.vertica.dk/2016/03/04/crm-2016-unable-to-login-to-dynamics-crm/:
WEBSITE_LOAD_USER_PROFILE=1 at appsettings
Nothing happens.
The authentication data and addresses are correct. It's only failed in the Azure enviroment.
Any solutions?
According to Kudu Configurable settings, WEBSITE_LOAD_USER_PROFILE is only available for sites running in Basic or Standard mode. Please check which Web App Plan pricing plan did you choose?
You can also check whether the WEBSITE_LOAD_USER_PROFILE has been applied successfully using Azure Kudu site. On CMD page, redirect to Users folder using 'CD D:\Users' command, you will see a user which has a same name as your web app. If the specific user doesn't not exists, it means the USER_PROFILE has not been loaded.
CD D:\Users