Delphi Microsoft Azure SDK

Microsoft Azure is a cloud computing service operated by Microsoft for application management via Microsoft-managed data centers. It provides software as a service (SaaS), platform as a service (PaaS) and infrastructure as a service (IaaS) and supports many different programming languages, tools, and frameworks, including both Microsoft-specific and third-party software and systems.

Our sgcOpenAPI Client Parser can read the OpenAPI / Swagger Amazon AWS specifications and create automatically client interfaces in 100% pascal code, so it can be integrated in any Delphi, CBuilder or Lazarus Application.

You can check here the full list of more than 650 Microsoft and Azure Services:

The list includes popular services like:

  • Microsoft Graph (Excel, Outlook, OneDrive...)
  • Azure AD
  • Azure Backup
  • Azure SQL
  • And much more!!!!

Microsoft Azure Client 

The sgcOpenAPI Microsoft Client (TsgcOpenAPI_Microsoft_Client) has it's own OpenAPI Client which inherits from TsgcOpenAPI_Client.

This component has a property called MicrosoftOptions that includes all required configurations to connect to Microsoft Servers.


The OpenAPI Microsoft client allows to authenticate using the following methods:

  1. OAuth2 Code: is interactive, which means requires the intervention of the user.
  2. OAuth2 Credentials: is non-interactive, so can run as a service for example.

The authentication is configured in the property MicrosoftOptions.Authentication, allows the following values:

  • oamaOAuth2Code: interactive.
  • oamaOAuth2Credentials: non-interactive.

Other properties required by Microsoft are the following:

  • TenantId: it's a value that identifies your account, you can find in your Microsoft/Azure account.

OAuth2 Credentials 

Using OAuth2 Code Grant Flow doesn't requires interaction with the user, so is suitable for services, daemons... or any application that must run without user interaction.

Once you have the Tenant Id and the Credentials, you can configure the OAuth2 properties for Code Grant.

To configure the OpenAPI Client for OAuth2 Code Grant, configure the property MicrosoftOptions.Authentication with the following value:

GetOpenAPIClient.MicrosoftOptions.Authentication := oamaOAuth2Credentials;
GetOpenAPIClient.Authentication.OAuth2.AuthorizationServerOptions.AuthURL := '';
GetOpenAPIClient.Authentication.OAuth2.AuthorizationServerOptions.TokenURL := '';
GetOpenAPIClient.Authentication.OAuth2.OAuth2Options.ClientId := '90945b8d-f6b7-4b97-b2bd-21c3c90b5f3b';
GetOpenAPIClient.Authentication.OAuth2.OAuth2Options.ClientSecret := 'client_secret';
GetOpenAPIClient.Authentication.OAuth2.LocalServerOptions.IP := '';
GetOpenAPIClient.Authentication.OAuth2.LocalServerOptions.Port := 8080;
GetOpenAPIClient.Authentication.OAuth2.LocalServerOptions.SSL := True;
GetOpenAPIClient.Authentication.OAuth2.LocalServerOptions.SSLOptions.Port := 8080;
GetOpenAPIClient.Authentication.OAuth2.LocalServerOptions.SSLOptions.CertFile := 'sgc.pem';
GetOpenAPIClient.Authentication.OAuth2.LocalServerOptions.SSLOptions.KeyFile := 'sgc.pem';
GetOpenAPIClient.Authentication.OAuth2.LocalServerOptions.SSLOptions.Password := '';
GetOpenAPIClient.Authentication.OAuth2.LocalServerOptions.RedirectURL := 'https://localhost:8080';
GetOpenAPIClient.Authentication.OAuth2.AuthorizationServerOptions.Scope.Text := 'openapi'; 

The Tenant ID must be configured for the Authentication and Token URLs, just replace the correct Tenant Id in the url.

Microsoft only allows the URL localhost if you are listening in the Local IP, so set the redirect URL with localhost as dns name instead of configure with the IP address.

The scope value depends of the API, check the Microsoft / Azure documentation for every API.

OAuth2 credentials doesn't require any user interaction, so no browser will be opened the first HTTP request call.

Delphi Microsoft Azure SDK Video 

Delphi Azure SDK

List of Azure Services that integrates with sgcOpenAPI Azure SDK for Delphi, CBuilder and Lazarus.

Delphi Microsoft SDK

List of Microsoft Services that integrates with sgcOpenAPI Azure SDK for Delphi, CBuilder and Lazarus.
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

Delphi Google Sign-In Login
Delphi Google Cloud SDK

Related Posts