Set Up Syncing between D365 V9 On Premise and Exchange Online

by | Updated August 14, 2020 | Dynamics CRM

Recently, I set up D365 V9 on-premise server-side sync with Exchange Online. I ran into some tricky areas in the process. I am going to document them here. My goal is to help you have a smoother experience. Oh, and so I have it documented for the next time I need it. It will be needed every time the SSL Certificate expires and is changed. Below are the links I used as a guide to accomplish this task. I will walk through the steps and highlight additional information. I am writing in August of 2020. I note this date since Microsoft makes changes on a regular basis.

Warning: This is a techy blog. Continue at your own risk.

This first page includes the steps to connect D365 on-prem to Exchange online. This page is dated 11/19/2018.

Here’s how to get started with your sync:

1. Permission required

  • This refers to the account you will use to remote to the D365 servers and execute the tasks in the documents. Ex: Contoso\D365InstallAcct
    • D365 access with System Administrator Security Role
    • Local Admin on all D365 Servers
    • Full Control access to SSL Certificates on all D365 Servers
    • Office 365 Global Administrator Membership
      • Required to run PowerShell commands that access Office 365, Azure and Exchange online.
      • This is a temporary requirement and can be removed once the setup is complete.

2. Prerequisites

Hybrid Connector

  • An x509 digital certificate. I recommend a wild card cert. Ex: *
    • The SSL certificate must be installed on all D365 Servers. Your D365 Asysnc service account and the D365 Application service account must have read access to the certificate.
  • Install MS Online Service Sign-In Assistant.
  • Install the Azure Active Directory Module for Windows PowerShell
    • This is a PowerShell Module. I recommend you use PowerShell ISE on the D365 server. As you can see in the image, PS ISE gives you a script pane and execution pane. It also allows you to run snippets from your script. Save the whole script for later reference and when you need to run it to update the SSL Certificate.
    • You will see the command is
      • Install-Module MSOnline
        • You will get prompted for approval to install. You need to approve it or nothing will work.

PowerShell ISE

3. Set up server-based authentication

  • Again, I recommend using PowerShell ISE. This should be run on the D365 front end server. The first thing after opening PS ISE is to set the location to “C:\Program Files\Dynamics 365\Tools”. This location is based on where you installed D365.
  • Prepare the certificate.
    • You need to export the certificate to a location on the hard drive. Such as C:. This is only needed for the scripts that follow and can be removed one complete. You will need the following files export from the certificate.
      • Personalcerfile.cer
      • Personalcertfile.pfx
    • For this PowerShell command, you will also need the password for the certificate and the account to access it.
      • replace “personal_certfile_password” with the actual password
      • replace “consoto\administrator” with the account you setup as the D365 application service account. Make sure it is in the format, domain\account.
  • Prepare the Windows PowerShell session.
    • There is a typo in this MS Script.
    • Use “Install-Module MSOnlineExt -force” instead of “Install-Module MSOnlineExtended -force”
  • Connect to Office 365
    • When this portion of the script runs, it will open a windows credentials prompt. I had to use the email format of the account. Ex:


  • Set the certificate
    • Make user when copying PS commands from the web page to change the quotes in the command.
      • “ and ” to “
  • Set the Azure Active Directory Service Principal Name (SPN) in Exchange Online.
    • Again, check to change the quotes when copying.
    • In the first line, change “*” to “*”.
      • it should match the @ portion of the accounts email format.
        • Ex:
    • Leave the 2nd line as it. Not need to change the guide.
  • Configure the Microsoft Dynamics 365 Server for server-based authentication with Exchange Online.
    • The only thing here is to change the quotes when copying the script.

4. Set the Exchange Online tenant ID

  • Azure Active Directory module.
    • These PS commands retrieve and display the Tenant GUID.
    • This GUID is used in the next set of PS commands.
  • Update S2STenantId
    • Replace “Organizationname” with the name of the D365 Instance. This is the name that shows up in the D365 Deployment Manager in the D365 Server.

Deployment Manager

    • Replace “ExchangeOnlineTenantID” with the Tenant Guide.
    • See the highlighted text in the image below for text to be replaced.


    • Nothing else in this snippet needs to be changed.

The next steps refer to the following link dated 12/13/2019. This is a good page to read through completely. For this blog, we will look at the following sections.

Configure Windows Server for Dynamics 365 Customer Engagement (on-premises) applications that use OAuth.

  • Enable forms authentication
    • This is done in ADFS. You may have already done this when setting up D365 to be externally facing.
  • Configure the OAuth provider
    • These commands can be run from the same PS IDE as all the previous commands. The commands will Enable OAuth for your D365 installation.

Now you are ready to set up the Email Server profile in D365.

1. Create Hybrid Email Server Profile

2. Configure User’s mailboxes

  • Server-Side Sync or Email Router for Incoming and Outgoing Email
  • Approve Email
  • Test & Enable Mailbox

3. Settings > Dynamics 365 App for Outlook

  • Run the command from the Setup section on the ADFS server
    • Add-AdfsClient -Name “Dynamics 365 App for Outlook” -ClientId <Guid> -RedirectUri <D365 URL>/crmmailapp/code_auth.aspx
      • <Guid> is the unique id of the D365 instance.
      • <D365 URL> is the URL of D365
        • Ex:
  • Click Add App for all eligible users or Select users and click Add App to Outlook

Add App to Outlook

    • Thank can take some time. I have seen it take 15 minutes or more.
    • The User may have to close outlook or logoff

Thank you for taking the time to read this blog. I hope you find it helpful and remember, you’ll need to run through this process each time you update your SSL Certificate.


Related Posts


Submit a Comment

Your email address will not be published. Required fields are marked *

Upcoming Events


03mar10:00 am10:30 amThe Modern Manufacturer - MRP vs. MPS – What, When and How

03mar2:00 pm2:30 pmLot Management Best Practices for Batch Manufacturers

10mar10:00 am10:30 amEnhancing the Customer Experience and Driving More Business with Dynamics 365 Customer Service

10mar2:00 pm2:30 pmThe Five Steps to Managing Sales Tax

11mar11:00 am12:00 pmConfab with Stoneridge - Livestream - Power Apps Component Framework Power Hour

17mar10:00 am10:30 amThe Modern Manufacturer: Pro Tips for your Finance Team

24mar10:00 am10:30 amUnlock the Potential of Digital Marketing with Dynamics 365 Marketing

25mar11:00 am12:00 pmConfab with Stoneridge - Livestream - The Four Keys to Choosing the Best ERP or CRM Solution

31mar10:00 am10:30 amThe Modern Manufacturer: Keys to Reporting Success

31mar01aprTraining Class: Financial Reporting W/Account Schedules for Dynamics 365 Business Central


31mar01aprTraining Class: Financial Reporting W/Account Schedules for Dynamics 365 Business Central

07apr10:00 am10:30 amBoost Seller Productivity and Close More Business with Dynamics 365 Sales

07apr2:00 pm2:30 pmEnsuring Quality for Batch Manufacturers

08apr11:00 am12:00 pmConfab with Stoneridge - Livestream - Jumping into the Deep End of the Data Lake

14apr10:00 am10:30 amThe Modern Manufacturer: Cost Accounting in D365

21apr12:00 pm1:00 pmGetting Started with Barcode Scanners and WMS Apps for Business Central

22apr11:00 am12:00 pmConfab with Stoneridge - Livestream - Moving from Manual to Automated with Strategic Automation Strategies

28apr10:00 am10:30 amThe Modern Manufacturer: Best Practices for Inventory Turn

28apr12:00 pm1:00 pmPower Up Microsoft Dynamics by Automating Budgeting, Dashboarding and Reporting

About Stoneridge
Stoneridge Software is a unique Microsoft Gold Partner, with emphasis on partner. With specialties in Microsoft Dynamics 365, Microsoft Dynamics AX, Microsoft Dynamics NAV, Microsoft Dynamics GP and Microsoft Dynamics CRM, we focus on attracting the most knowledgeable experts in the field to our team, and prioritize delivering stellar solutions with maximum impact for your business. At Stoneridge, we are deeply committed to your results. Each engagement is met with a dedicated team, ready to provide thorough, tailored, and expert service. Based in Minnesota, we intentionally “step into your shoes,” wherever you are. We focus on what you care about, and develop trusting, long-term relationships with our clients.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!