Skip to main content

azure_graph_users Resource

Use the azure_graph_users InSpec audit resource to test the properties of some or all Azure Active Directory users within a Tenant.

Azure REST API Version, Endpoint, and HTTP Client Parameters

This resource interacts with API versions supported by the resource provider. The api_version can be defined as a resource parameter. If not provided, this resource uses the latest version. For more information, refer to the azure_generic_resource document.

Unless defined, this resource uses the azure_cloud global endpoint and default values for the HTTP client. For more information, refer to the resource pack README.


This resource is available in the Chef InSpec Azure resource pack.

For information on configuring your Azure environment for Chef InSpec and creating an InSpec profile that uses the InSpec Azure resource pack, see the Chef InSpec documentation for the Azure cloud platform.


An azure_graph_users resource block returns all Azure Active Directory user accounts within the configured Tenant and then tests that group of users.

describe azure_graph_users do


The following parameters can be passed for targeting specific users.

A hash containing the filtering options and their values. The starts_with_ operator can be used for fuzzy string matching. Parameter names are in the snake case.

Example: { starts_with_given_name: 'J', starts_with_department: 'Core', country: 'United Kingdom', given_name: John}

OData query string in double quotes, ". Property names are in the camel case. Refer to here for more information.

Example: "startswith(displayName,'J') and surname eq 'Doe'" or "userType eq 'Guest'"

It is advised to use these parameters to narrow down the targeted resources at the server side, Azure Graph API, for a more efficient test.


The unique identifiers of users.

Field: id

The unique identifiers of users. This is for backward compatibility. Use ids instead.

Field: id

The display names of users.

Field: displayName

The given names of users.

Field: givenName

The job titles of users.

Field: jobTitle

The email addresses of users.

Field: mail

The user types of users. For example, Member, Guest.

Field: userType

The user principal names of users. For example,

Field: userPrincipalName


For information on using filter criteria on plural resources, see the documentation on FilterTable


The following examples show how to use this InSpec audit resource.

Check users with some filtering parameters applied at server side (Using ‘filter’)

describe azure_graph_users(filter: {given_name: 'John', starts_with_department: 'Customer'}) do
  it { should exist }

Check users with some filtering parameters applied at server side (Using ‘filter_free_text’)

describe azure_graph_users(filter_free_text: "startswith(givenName,'J') and startswith(department,'customer') and country eq 'United States'") do
  it { should exist }

Ensure there are no guest accounts active (Client Side Filtering)

describe azure_graph_users.guest_accounts do
  it { should_not exist }


For a full list of available matchers, see our Universal Matchers page.

This resource has the following special matchers.


The control passes if the filter returns at least one result. Use should_not if you expect zero matches.

describe azure_graph_users do
  it { should exist }

Azure Permissions

Graph resources require specific privileges granted to your service principal. Please refer to the Microsoft Documentation for information on how to grant these permissions to your application.

Edit this page on GitHub

Thank you for your feedback!


Search Results