Install ADFS on Azure VM step by step

In this article, we will install the ADFS in Azure VM.

Prerequisites:

  • Create a Service Account with Domain/Enterprise Admin rights
  • Cloud only account with Global Admin rights
  • Third-party SSL certificate
  • AAD Connect (Directory Sync)

Steps we will take in this lab.

  • Install ADFS Server
  • Import Certificate and complete the Setup
  • Post Install testing
  • Setting up DNS record and open firewall port
  • Convert domain to federated
  • Test the working of the ADFS.

Step 1 - Install the ADFS server, join the server to the domain and reboot.

POWERSHELL
Install-windowsfeature adfs-federation –IncludeManagementTools

Step 2 Create a certificate request.

In the lab, I am using the LetsEncrypt free cert so I will skip the steps. if you would like to see how I

got this cert, please check out my this post.

Step 3) Add KDS Root key

Enable gMSA in your domain by running the following Windows PowerShell command on a domain controller, which runs Windows Server 2012 or later.

POWERSHELL
Add-KdsRootKey –EffectiveTime (Get-Date).AddHours(-10)

Step 4) Configure the first federation server in a new federation server farm

Open the Server Manager, and click on "Configure the federation service on this Server"

that should open the below dialogue box, hit next.

specify the account details.

Import the certificate we exported in (.pfx) format in the previous step, and provide the "Federation Service Display Name"

Provide the service account details.

Continue with the default selection.

review the selection and click next.

If all the Pre-requisite checks are pass click on " Configure" to continue.

you should the screen like below after a successful configuration.

Next, let's test the ADFS.

Note: Before we can test, make sure you have DNS record set up so that URL "sts.lab365.in" is resolvable and can reach the ADFS server, also for the service to be available externally, open the port 443 in the firewall, and publish CNAME record in the DNS, in my Azure LAB "sts.lab365.in" point to my VM external URL which would be like "adfs01.westindia.cloudapp.azure.com".

Once all the DNS records are setup we can use the below URL, which should return the XML.

https://sts.lab365.in/adfs/fs/federationserverservice.asmx

Also, check the LDAP Signon page URL if it's working.

https://ADFS_FQDN/adfs/ls/idpinitiatedSignOn.aspx

Note that you need the enable it before testing, as its disabled by default.

POWERSHELL
Set-AdfsProperties –EnableIdpInitiatedSignonPage $True

Step 5) - Configure Federation Trust with Office 365

IMPORTANT:
2026 Update: The MSOnline module used in the original post (Connect-MsolService, Convert-MsolDomainToFederated) is retired and no longer works. Use one of the supported methods below. The original commands are kept at the end of this step for reference.

The easiest supported method is Microsoft Entra Connect. It configures both sides of the trust: the federated domain in Entra ID and the Microsoft Office 365 Identity Platform relying party trust on AD FS.

  1. Open Microsoft Entra Connect on your sync server and select Configure.
  2. Choose Manage federation → Federate an Azure AD domain (if AD FS was not deployed through the wizard, first choose Change user sign-in → Federation with AD FS).
  3. Point it at your AD FS farm (adfs02.lab365.in), select the domain lab365.in, and finish the wizard.
  4. Use Verify federation connectivity on the last page to confirm.

Option B: Microsoft Graph PowerShell

If you manage the AD FS relying party trust yourself, you can federate the domain in Entra ID with Graph PowerShell. Run this on the AD FS server so you can read the token-signing certificate and federation properties:

POWERSHELL
Install-Module Microsoft.Graph.Identity.DirectoryManagement -Scope CurrentUser -Repository PSGallery
Connect-MgGraph -Scopes "Domain.ReadWrite.All", "Directory.AccessAsUser.All"

$domain  = "lab365.in"
$fsProps = Get-AdfsProperties
$fsHost  = $fsProps.HostName                       # e.g. adfs02.lab365.in
$signing = Get-AdfsCertificate -CertificateType Token-Signing | Where-Object IsPrimary
$certB64 = [System.Convert]::ToBase64String($signing.Certificate.RawData)

New-MgDomainFederationConfiguration -DomainId $domain `
    -DisplayName "LAB365 AD FS" `
    -IssuerUri "http://$domain/adfs/services/trust/" `
    -PassiveSignInUri "https://$fsHost/adfs/ls/" `
    -ActiveSignInUri "https://$fsHost/adfs/services/trust/2005/usernamemixed" `
    -SignOutUri "https://$fsHost/adfs/ls/?wa=wsignout1.0" `
    -MetadataExchangeUri "https://$fsHost/adfs/services/trust/mex" `
    -SigningCertificate $certB64 `
    -PreferredAuthenticationProtocol "wsFed" `
    -FederatedIdpMfaBehavior "acceptIfMfaDoneByFederatedIdp"

# Verify
Get-MgDomainFederationConfiguration -DomainId $domain | Format-List
Get-MgDomain -DomainId $domain | Select-Object Id, AuthenticationType
WARNING:
Option B only configures the Entra ID side. The AD FS relying party trust for urn:federation:MicrosoftOnline (with its issuance transform rules) must already exist, and the IssuerUri must match the issuer AD FS puts in its tokens. A mismatch causes AADSTS50107 errors. You can't federate the tenant's default domain or an onmicrosoft.com domain.
TIP:
Microsoft now recommends cloud authentication (Password Hash Sync or Pass-through Authentication) over AD FS for most organizations. If you are building AD FS in 2026 only for Microsoft 365 sign-in, consider PHS with Conditional Access and staged rollout instead.
Original 2019 commands (retired MSOnline module)
POWERSHELL
Connect-MsolService
Set-MsolADFSContext -computer adfs02.lab365.in
Convert-MsolDomainToFederated -domain lab365.in

Step 6) - Sync local Active Directory user accounts to Office 365

Now run the AD Connect sync if not already run and the users should now be redirected to ADFS for authentication.

This completes my post in setting up ADFS on Azure VM, where we successfully installed, configured and tested the ADFS.