4. Azure Integration

In order for TrustView to gain access to Microsoft Azure, some requirements must be met. Follow the steps below to set up the integration.

Important

The secrets, keys and certificates stored inside a key vault, and an application’s client secret or certificate credentials, must have an expiry date set in Azure to be shown in TrustView, once the integration has been successfully configured. The key vault or the app registration itself does not need an expiry date - only its individual secrets, keys, certificates or credentials do. So if you experience that elements are missing or not listed, check that an expiry date has been set on each individual secret, key, certificate or credential.

4.1. Prerequisites

This integration requires the Automation permission on your TrustView role - read to view a configured Azure integration, write to add, edit or delete one. The built-in roles already have the right access (see the “View/Manage the Automation module” rows under Overview of roles) and can’t be changed - this choice only needs to be made explicitly when defining a custom role.

4.2. Create app registration

Create an app registration that should be used for TrustView, to access Azure APIs:

Before creating an App registration, go to the Azure portal where you create your Azure Key Vaults, and make sure to set an expiration date for the secret, associated with the key vault that you want to see and get an overview of in TrustView.

Important

Enable the checkbox Set expiration date and then choose an expiration date for the Secret. Enabling this, when creating a new secret for a designated key vault, will allow you to then be able to not only see the key vault in TrustView, but also see the content of the key vault. If you do not set an expiration date, you will not be able to see the content of the key vault.

Go to Microsoft Entra and select App registration New registration

How to register an Azure application
  • Select a name and select Accounts in this organizational directory only (Single tenant)

  • Leave Redirect URI as blank, because it is not used

After creating the app, store the values of:

Application (client) ID - (client id) and Directory (tenant) ID  - (tenant id)

You then need to create a client secret. This can be done by choosing Add a certificate or secret and then choosing New client secret

Store the secret value.

The last thing needed is the subscription id, which can be seen by choosing Subscriptions under Azure services.

Store the subscription id.

We now have client id, client secret, tenant id and the subscription id available and saved.

In TrustView, choose Azure integration and type in the values and select a name and click Add to finish the setup.

Azure integration setup

The Azure integration is now configured in TrustView; however, the client needs some permissions in order to be allowed to list apps and key vaults:

  • Under the client overview page in Azure, go to App registrations then select API permissions and click Add a permission

  • Select Microsoft Graph application permissions Application.Read.All

Azure permissions
  • Select the next permission under Azure KeyVault user_impersonation

Azure Key Vault
  • Select Grant admin consent

Azure - grant admin consent

The client should now be able to list all apps located under the Azure subscription. The App also needs permission to find the key vaults. Do the following for every key vault that TrustView should read:

In Azure portal, select the key vault, click on Access control (IAM), then Add Add role assignment.

Azure access control

Under Job function roles, search for and select Reader, then click Next. On the Members tab, keep User, group, or service principal selected, click Select members, search for the App registration created above, select it and click Select. Lastly, click Review + assign.

Note

Reader is the smallest built-in role that lets TrustView find the key vault: TrustView lists key vaults through Azure Resource Manager, which only needs read access to the key vault itself. Earlier versions of this guide used Key Vault Contributor, which also allows changing the key vault and, on key vaults that use access policies, granting itself access to their contents. If the App registration already has Key Vault Contributor, you can replace it with Reader.

Reader only lets TrustView find the key vault. It gives no access to the keys, secrets and certificates stored in it, so the App registration also needs data access. How you grant it depends on the key vault’s permission model, shown in the key vault under Settings Access configuration.

If the key vault uses Azure role-based access control (recommended)

Azure role-based access control (RBAC) is the permission model Microsoft recommends, and the default for new key vaults. Under Access control (IAM), assign the App registration the roles below, the same way as Reader above:

  • To list keys, secrets and certificates in TrustView: Key Vault Reader

  • To also create and upload certificates to Azure from an automation task in TrustView: Key Vault Certificates Officer, Key Vault Crypto Officer and Key Vault Secrets User. Key Vault Secrets User is what lets TrustView retrieve the certificate’s private key material.

Role assignments can take a few minutes to take effect. See Microsoft’s Key Vault RBAC guide for details about each role.

If the key vault uses Vault access policy (legacy)

Note

Microsoft calls access policies a legacy permission model and recommends Azure RBAC. Switching a key vault to Azure RBAC makes its access policies stop working, so assign the roles above before you switch.

Click Access policies and click Create, and select these permissions:

  • To list keys, secrets and certificates in TrustView: List under Key Management Operations, Secret Management Operations and Certificate Management Operations.

  • To also create and upload certificates to Azure from an automation task in TrustView, add: Create (Key Management Operations), Sign (Cryptographic Operations), Get (Secret Management Operations), and Create, Import and Backup (Certificate Management Operations). Get on secrets is what lets TrustView retrieve the certificate’s private key material, and Import is used when TrustView uploads a certificate with its private key (PFX) to the key vault.

Click Next, search for the App registration, select it and click Next, and finally Create.

Repeat the above steps for all key vaults that TrustView should be able to read.

4.3. Deploying certificates to a Key Vault via an Automation task

Once the Azure integration above is configured with the required permissions, it can be used as the deployment target of an Automation task (see Automation). This is TrustView’s native route to a Key Vault: unlike the simple-acme ACME client walkthrough covered in Automation (which runs an external agent on a separate Windows server to issue the certificate and push it into the vault), this path needs no external host or client - TrustView deploys the certificate itself, directly through the Azure integration, on the Automation task’s own schedule.

When creating or editing the Automation task, choose this deployment type and fill in:

  • Azure instance - the configured Azure integration to deploy through.

  • Keyvaults - the key vault (among those listed for that integration’s subscription) to deploy the certificate to.

  • Certificates in keyvault - an existing certificate entry in that vault to update on renewal. Click Create new instead to deploy under a new name, and type it into the New certificate in keyvault field that appears (Select certificate switches back to picking an existing one).

The issued certificate is then deployed to that key vault entry automatically on the task’s schedule, alongside the other producer/key-container/deployment combinations Automation tasks support.

4.4. Quick overview of permissions and access rights

Here is a quick overview of what is needed. For a more detailed explanation, look at the guide above.

API Permissions

  • Microsoft Graph application permissions Application.Read.All

  • Azure KeyVault user_impersonation

  • Grant admin consent

Access control (IAM)

  • Key Vault Contributor

Access rights

  • Key Management Operations Create

  • Secret Management Operations Get

  • Cryptographic Operations Sign

  • Certificate Management Operations Create and Backup

  • All Management Operations List

4.5. Troubleshooting

If you don’t see any Azure key vaults listed on the detail page for the Azure integration (having multiple integration setups is possible), check the TrustView log files. If you are unsure how to find them, check here.

Example of lines to look for in the log files
1WARN --- [-nio-443-exec-2] c.m.tool.AzureIntegrationService         : No Azure oAuth2 token
2WARN --- [-nio-443-exec-2] c.management.tool.AzureProviderService   : Login failed with http status code 401. Response [trace_id:0ae00000-000f-000d-0f0b-000f00000000, error_description:AADSTS7000215: Invalid client secret provided. Ensure the secret being sent in the request is the client secret value, not the client secret ID, for a secret added to app 'app-id'

This could also be caused by having one or more leading and/or trailing whitespaces in your Client secret input field, so ensure that your Client secret does not contain any whitespaces.