Overview
A Service Principal is an identity created within your on-premises Active Directory (AD) and that is allowed to access one or more resources within your AD. You can delegate the minimum required permissions to the service principal so that it can be used to create a connection to Densify to collect data.Video: Data Collection Prerequisites for Azure Using a Service Principal
Video: Data Collection Prerequisites for Azure Using a Service Principal
Azure Stack is not supported. This data collection method currently only supports Azure Cloud.
- An application that is created within your . This application will be associated with the user that creates it.
- A service principal is then created for that application;
- The service principal is granted access to your Azure subscription.
In this case “federated” indicates that your on-premise Active Directory is linked with your Azure Cloud’s Entra ID so you can use your existing on-premise AD credentials to access your Azure portal.
Requirements to Create a Cloud Connection
To connect Densify to your Azure subscriptions, you need the following items to setup data collection:- Tenant ID/Directory ID
- Service Principal/Application ID
- Secret Key
- Subscription ID—Only required when using the Densify API.
Required Account Permissions
You must have admin/owner privileges for your Azure portal to create the account required for Densify. Typically, your on-premise Active Directory is federated with the Azure AD. In this case, the admin access is likely provided from an on-premise Active Directory account (via federation) and will possess the required Azure admin privileges. The user account/Service Principal to be used for data collection only requires the “Reader” role privileges to collect resource utilization data. If necessary you can configure a custom role that is more restrictive than the “Reader” role privileges. See Configuring a Role with Minimum Permissions for Data Collection for details.Obtaining the Tenant ID/Directory ID
The tenant ID corresponds to the Microsoft Entra ID.- Login into your Azure account and click on Microsoft Entra ID> Overview .
- In the Overview pane, copy the Tenant ID.
Figure: Entra ID Overview
Figure: Entra ID Overview

Obtaining the Application ID and Client Secret
You now need to create a new application registration. This will be the service principal for Densi. You will need the Application ID and corresponding client secret (key), to complete the Densify connection.- Click App Registration.
- In the App Registration pane, click New registration.
Figure: Create New Registration
Figure: Create New Registration

- In the Create pane enter the following information:
- The Name of the application (e.g. Densify_Connection).
- Select who can access the application. Leave the default of “Accounts in this organizational directory only (Default Directory only - Single tenant)”.
- Select the Redirect URI (optional) as “Web” and specify a Sign-on URI (e.g. https://Densify.com).
- Click Register to create and register the application. This is the service principal that Densify will use to collect data.
Figure: Configure the Registration
Figure: Configure the Registration

- Copy the Application ID (e.g. 7d16fbf8-1fc3-4e08-b48a-626). You need to copy this ID and save it to a location from which you can easily retrieve it. You will need the Application ID to create the Densify connection.
Figure: Obtain the Application ID
Figure: Obtain the Application ID

- Click Client credentials to see create the credential.
- Click on New client secret to create a new key.
- In the Add a new client secret pane, enter a Description (e.g. DensifyKey) and an expiration period (e.g. 1 year, 2 years or never expires).
- Click Add to create the key.
- Copy the secret key Value to a location from which you can easily retrieve it. You will need this key to create the Densify connection.
Figure: Generate the Secret Key
Figure: Generate the Secret Key

Obtaining the Subscription ID
If you are using the API, data collection and analysis are created and then refreshed daily on a per subscription basis (1-to-1). You can associate many subscriptions with a service principle, but when using the API to initiate data collection, you must specify a subscription ID and the audit and analysis are created for each subscription, separately. When using the Connection Wizard in the Densify UI, you do not need the subscription ID, as all subscriptions that are associated with the service principle are collected and listed once the connection has been verified. You can then select one or more of the subscriptions that you want to analyze (1-to-Many). When using the Connection Wizard, data collection and analysis are created and then refreshed daily for all of the subscriptions that you selected when you created the connection. Use the following instructions to get the Subscription ID.- Navigate to Subscriptions in the main menu. You may need to click on More services to see Subscriptions.
- Click on a subscription to open the configuration page.
- Copy the Subscription ID. You need to copy this ID and save it to a location from which you can easily retrieve it. You will need the Subscription ID to initiate data collection, when using the Densify API.
Assigning Access to Subscriptions
The application registered above, now needs access to each of your subscriptions. You need to assign the “Reader” role to the Application for each subscription being audited. Use the following process:- Navigate to Subscriptions in the main menu. You may need to click on All services to see Subscriptions.
- Click on a subscription to select and open the configuration pane.
Figure: Access Subscriptions
Figure: Access Subscriptions

- Click Access Control (IAM).
- Click Add > Add role assignment.
Figure: Access Role Assigment
Figure: Access Role Assigment

- In the Add role assignment pane select the Role of “Reader”.
- Click Next .
Figure: Access Add Role Assigment
Figure: Access Add Role Assigment

- On the Add role assignment pane, ensure Assign Access to is set to “User, group or service principal”.
- Click Select members.
- Search for or scroll to locate the service principle (Densify_Connection), created above.
- Click Select.
Figure: Add Role Assigment
Figure: Add Role Assigment

- The selected application will appear in the Members section.
- Click Review + Assign to save these changes.
Figure: Complete Role Assigment
Figure: Complete Role Assigment

- Repeat this process for each subscription to be included in Densify data collection.
Figure: Allow Application to access a Subscription
Figure: Allow Application to access a Subscription

Advanced Topics
The following sections contain detailed instructions for more advanced configuration. Some sections are referenced in the procedures above. Other advanced topics cover optional configuration.- Configuring a Role with Minimum Permissions for Data Collection
- Create the Service Principal Through the Azure CLI
Configuring a Role with Minimum Permissions for Data Collection
To simplify setup and maintenance of the role used for performing data collection, Densify recommends using the “Reader” role. This role provides read-only access to your Azure services and resources and supports the requirements for resource utilization data collection. As the Densify continues to evolve and expand, you do not need to update permission policy to include newly added services and features, when using the “Reader” role. Alternatively, if you must restrict the role with the minimum permissions you can create a custom role with only the required permissions. These custom roles provide an alternative method for granting permissions that are more restrictive than the built-in “Reader” role. These custom roles (JSON) define the minimum permissions required by Densify to collect resource utilization metrics data, respectively. The “Densify Resource Utilization Metrics Reader” custom role grants read-only permissions for collecting data related to VMs, SQL servers and reservations in the subscriptions specified in the assigned scope. Custom Role: Densify Resource Utilization Metrics Reader- Copy the above sample and save it as JSON files.
- Login into your Azure account. You must have admin or owner privileges for your Azure portal. See Microsoft Azure Data Collection Prerequisites for a Service Principal.
- Navigate to Subscriptions in the main menu. You may need to click on All services to see Subscriptions. Select a subscription.
- Click Access Control (IAM).
- Click Add > Add custom role.
- In Create a custom role, select Start from JSON and then select one of the custom role JSON files, that you saved above. The role name and description fields are populated with details from the JSON file. The file will also be validated.
- Click Next and review the list of permissions.
- Click the Assignable scope tab and select subscription as the Type. Select the subscriptions to which the custom role will be assigned.
- Click the JSON tab to review your settings and then create the custom role and click Save.
- Assign the custom role to the Densify service principal. See Assigning Access to Subscriptions.