How to Publish D365 F&O Custom Services Using Azure API Management

If you’re here, chances are you’ve already built and deployed a custom service in Dynamics 365 Finance & Operations. Maybe you’ve tested it using the metadata URL and confirmed it’s returning the right response. Now, you want to make that service available securely and cleanly to external consumers — whether it’s for a portal, mobile app, or third-party integration. That’s exactly where Azure API Management (APIM) fits in.

This guide walks you through the complete process of exposing your D365 F&O custom service through APIM — including authentication, subscription control, and real-time testing. Whether you’re doing this for the first time or setting it up in a new environment, follow each step carefully to avoid common pitfalls.

1. Ensure the Custom Service Is Deployed and Reachable

Before configuring anything, confirm the service is working by opening the following in a browser:

https://<your-d365fo-url>/api/services/<ServiceGroup>/<Service>

If you receive a valid metadata or JSON response, you’re good to proceed. If not, troubleshoot your
service deployment first.

2. Register an Azure AD App

This app will help APIM authenticate with D365 F&O using OAuth.

Step-by-step:

  • Go to Azure Portal → Azure Active Directory → App registrations
  • Click New registration
  • Name: D365FO-APIM-App
  • Supported account types: Single tenant
  • Leave the Redirect URI empty for now
  • Click Register

Next, give this app the required permissions.

Follow-up:

  • Go to API permissions → Add a permission
  • Select Dynamics ERP → Delegated Permissions
  • Add: user_impersonation
  • Click Grant admin consent
  • Now, go to Certificates & secrets → New client secret
    • Add a description and set expiry
  • Save the value — you’ll need it later

3. Trust the App in D365 F&O

Now that your app is registered, it needs to be recognized by your D365 environment.

Do this inside D365 F&O:

  • Go to System administration → Setup → Azure Active Directory applications
  • Click New
    • Client ID: Paste the App (Application) ID from Azure
    • Name: A user-friendly label
    • User ID: Choose a valid system user account (used by the app)

This maps the Azure AD app to a D365 F&O user, giving it permissions to access services.

4. Create an API Management Instance in Azure

APIM acts as your API gateway. You’ll now set it up.

To do this:

  • In Azure Portal, go to API Management Services → +Create
  • Provide:
    • Name, Subscription, Resource Group
    • Region, Organization Name, Admin Email
  • Choose pricing tier (Developer is ideal for testing)
  • Click Create

⚠️ Note: It may take 20–30 minutes to fully provision the instance.

5. Import the Custom Service into APIM

Once APIM is ready, you’ll add your custom service as a new API.

Steps:

  • Go to your APIM instance → APIs → +Add API → HTTP
  • Set:

Web service URL:

https://<your-d365fo-url>/api/services/<ServiceGroup>/<Service>

  • Display Name: e.g. D365CustomService
  • Name and URL Suffix: e.g. d365custom
  • Description, legal terms, etc.


  • Click Create

Then, manually define operations — or import if you have an OpenAPI (Swagger) file.

6. Add an Inbound Policy for OAuth Token

To allow APIM to securely talk to D365 F&O, configure the inbound policy to fetch a bearer token using your app’s credentials.

Steps:

  • In your APIM instance, go to “OAuth 2.0 + OpenID Connect” section.
  • Click “+Add” button
  • Click Add policy → Advanced editor

Fill in the necessary details and hit the Create button.

This step ensures that APIM can authenticate requests to the backend securely.

7. Create a Product and Add Subscription Control

To control who can access your API, add a product in APIM and bind your API to it.

Do this:

  • In your APIM instance, go to the “API” tab.
  • Select “+Add API”
  • Click “Blank API”


Fill out the necessery values like, name, Web service URL, and API URL suffix.

  • Click the Create button.

8. Test the Setup End-to-End

Let’s verify that the full flow works.

Publish Developer Portal

For the first time, we need to publish developer portal for our APIM instance.

  • Go to “Portal overview” section.
  • Publish Your Developer Portal.

Open Developer Portal

  • Go to “Overview” section.
  • Under “Properties” tab, go to “Developer portal”.
  • Open Portal in “Administrative interface” mode.
  • Click on “Developer Portal” to access your portal.
  • Find and select “APIs”, there you should be able to see your Custom API.
  • Click on your API.
  • Select Operation and Click on “Try it”
  • Define the following values and hit the “Send” button to call your custom service as an API.

9. Monitor and Document

Use APIM’s Analytics and, optionally, Application Insights to track:

  • Request volume
  • Response times
  • Errors
  • User activity

Final Thoughts

Publishing a custom service from D365 F&O to the outside world isn’t just about opening a URL — it’s about securing access, controlling usage, and ensuring maintainability. Azure API Management brings all of that into one place.

With this setup, you’ve:

  • Registered and secured an Azure AD app
  • Trusted it in D365
  • Created an API proxy using APIM
  • Added subscription control
  • Tested and validated the setup
  • Enabled monitoring and documentation

Leave a Reply

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