Reader small image

You're reading from  Administrating Microsoft Dynamics 365 Business Central Online

Product typeBook
Published inJul 2022
PublisherPackt
ISBN-139781803234809
Edition1st Edition
Right arrow
Author (1)
Andrey Baludin
Andrey Baludin
author image
Andrey Baludin

Andrey Baludin is a solution architect and is currently employed with Awara IT Solutions (Gold Microsoft Partner). His educational qualifications includes a masters degree from St.Petersburg Polytechnic University. Andrey is a Microsoft MVP and has been working with Microsoft Dynamics NAV since 2008 from 5.0 to the latest versions of Dynamics 365 Business Central. Andrey is a real fan of Business Central and Azure, and his specialization is integrating Business Central with everything
Read more about Andrey Baludin

Right arrow

Chapter 7: Admin Center APIs

If you have repeatable actions with Dynamics 365 Business Central environments, want to automate some tasks, or even create your own interface for the Admin Center, you can make use of the Admin Center application programming interfaces (APIs). You could perform almost all these actions without opening the Admin Center. Create and delete environments, schedule updates, and set up notifications—you could run all these operations with a few clicks by calling the APIs.

In this chapter, we are going to cover the following main topics:  

  • Setting up API authentication
  • Calling APIs
  • Application APIs
  • Environment operations APIs
  • Environment settings APIs
  • Other APIs

By the end of this chapter, you will be able to set up API authentication; you will also know which APIs exist for the Admin portal and how to call them with PowerShell and Postman.

Setting up API authentication

For authentication, Admin Center APIs use Open Authorization 2.0 (OAuth 2.0) with Azure Active Directory (Azure AD). You must create an Azure app registration and let it call your Admin Center API. The process might be a bit tricky initially, but after a bit of practice, it should get a lot easier. Follow these steps to set up API authentication:

  1. Open the Azure portal and find App registrations. Click on + New registration to begin the process, as illustrated in the following screenshot:

Figure 7.1 – New app registration

  1. In the second step, fill in a Name value for the app—for example, Business Central. For the Supported account types section, choose who will use the API—accounts from only your tenant or somebody else. Then, choose Public client/Native as the Redirect URIs value and type BusinessCentralWebServiceClient://auth in the box next to it. Click on Register to continue. The process...

Calling APIs

In this section, we will learn how to call Admin Center APIs. I suggest doing this in two different ways, as follows:

  • From PowerShell, to show automation scenarios
  • From Postman, to show a user-friendly interface

For example, you often update development sandboxes from a test or production sandbox, and you don't want to open the Admin portal each time and click through all those settings. You could create a PowerShell script and just run it each time you need to have a new environment.

Postman is one of the most popular REpresentational State Transfer (REST) clients. You can use it to test APIs, for single calls or demonstration purposes.

In this section, we will look into both environments.

PowerShell

  1. Run PowerShell as an administrator. We need to install the AzureAD module and the Microsoft.Identity.Client package (if you haven't already done so). For this, run the next script:
    Install-Module AzureAD
    Install-Package -Name...

Application APIs

In this section, we meet the APIs related to application management (AM)—lists, installation, and other operations. You can always check the latest changes in the APIs— more details are available here: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/administration-center-api_app_management.

Here are some commonly used parameters:

  • {applicationFamily}: Application family of the environment. This is usually "businesscentral", but it could be different for independent software vendor (ISV) solutions.
  • {environmentName}: Name of your environment.

Further, I will give you an API name, a short description (if the name is not obvious), the required method, headers, a URL, and the body's parameters. Let's get started.

Installed apps list

Here are details of the apps list that was installed in your environment:

  • Method: GET
  • URL: https://api.businesscentral.dynamics...

Environment operations APIs

In this section, we meet APIs for environment operations—listing, creating, deleting, backup, and so on.

Detailed information about environment operations updates can be found here:

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/administration-center-api_environments

Environment list

This API is used to return a list of your environments. You could specify the application family to get environments only related to it. It has the following parameters:

  • Method: GET
  • URL without application family: https://api.businesscentral.dynamics.com/admin/v2.11/applications/environments

URL with application family: https://api.businesscentral.dynamics.com/admin/v2.11/applications/{applicationFamily}/environments

Getting an environment

This API is used to return environment details selected by the application family and a specified name. It has the following parameters:

  • Method: GET...

Environment settings APIs

This API group is used to get or update different environment settings.

Detailed information on the environment settings API is available here:

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/administration-center-api_environment_settings

Getting an environment update window

This API responds with the environment update preferred start and end time in UTC.

It has the following parameters:

  • Method: GET
  • URL: https://api.businesscentral.dynamics.com/admin/v2.11/applications/{applicationFamily}/environments/{environmentName}/settings/upgrade

Changing an environment update window

This API is used to change your environment update window.

It has the following parameters:

  • Headers: Content-Type: application/json
  • Method: PUT
  • URL: https://api.businesscentral.dynamics.com/admin/v2.11/applications/{applicationFamily}/environments/{EnvironmentName}/settings/upgrade
  • Body...

Other APIs

This section contains APIs that you can use to perform some other operations.

Information on other APIs can be found here:

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/administration-center-api_notifications

Notification settings list

This API is used to get all notification recipients that were assigned to the tenant.

It has the following parameters:

  • Method: GET
  • URL: https://api.businesscentral.dynamics.com/admin/v2.11/settings/notification/recipients

Creating a notification recipient

This API is used to add a notification recipient to the tenant.

It has the following parameters:

  • Headers: Content-Type: application/json
  • Method: PUT
  • URL: https://api.businesscentral.dynamics.com/admin/v2.11/settings/notification/recipients
  • Body parameters, as described in the following table:

Table 7.12

This is a sample of a notification recipient creation:

...

Summary

This is the last chapter of the first part of the book. You made a big step forward and got a new professional skill—you learned how to automate your administration routine. You are able to create automation scripts and perform single calls with Postman. You know which tasks you are able to automate. And after all this information about the Admin Center, we will move on to cloud migration in the second part of the book.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Administrating Microsoft Dynamics 365 Business Central Online
Published in: Jul 2022Publisher: PacktISBN-13: 9781803234809
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Andrey Baludin

Andrey Baludin is a solution architect and is currently employed with Awara IT Solutions (Gold Microsoft Partner). His educational qualifications includes a masters degree from St.Petersburg Polytechnic University. Andrey is a Microsoft MVP and has been working with Microsoft Dynamics NAV since 2008 from 5.0 to the latest versions of Dynamics 365 Business Central. Andrey is a real fan of Business Central and Azure, and his specialization is integrating Business Central with everything
Read more about Andrey Baludin