Options
All
  • Public
  • Public/Protected
  • All
Menu

Class KeyVaultAccessControlClient

Package version

The KeyVaultAccessControlClient provides methods to manage access control and role assignments in any given Azure Key Vault instance. The client supports creating, retrieving and deleting roles.

Hierarchy

  • KeyVaultAccessControlClient

Index

Constructors

constructor

  • Creates an instance of the KeyVaultAccessControlClient.

    Example usage:

    import { KeyVaultAccessControlClient } from "@azure/keyvault-admin";
    import { DefaultAzureCredential } from "@azure/identity";
    
    let vaultUrl = `https://<MY KEY VAULT HERE>.vault.azure.net`;
    let credentials = new DefaultAzureCredential();
    
    let client = new KeyVaultAccessControlClient(vaultUrl, credentials);

    Parameters

    • vaultUrl: string

      the URL of the Key Vault. It should have this shape: https://${your-key-vault-name}.vault.azure.net

    • credential: TokenCredential

      An object that implements the TokenCredential interface used to authenticate requests to the service. Use the @azure/identity package to create a credential that suits your needs.

    • Default value pipelineOptions: AccessControlClientOptions = {}

    Returns KeyVaultAccessControlClient

Properties

vaultUrl

vaultUrl: string

The base URL to the vault

Methods

createRoleAssignment

  • Creates a role assignment in an Azure Key Vault.

    Example usage:

    const client = new KeyVaultAccessControlClient(url, credentials);
    const roleDefinition = await client.listRoleDefinitions("/").next();
    const principalId = "4871f6a6-374f-4b6b-8b0c-f5d84db823f6";
    const result = await client.createRoleAssignment("/", "295c179b-9ad3-4117-99cd-b1aa66cf4517", roleDefinition, principalId);
    summary

    Creates a new role assignment.

    Parameters

    • roleScope: RoleAssignmentScope

      The scope of the role assignment.

    • name: string

      The name of the role assignment. Must be a UUID.

    • roleDefinitionId: string

      The role definition ID used in the role assignment.

    • principalId: string

      The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security group.

    • Optional options: CreateRoleAssignmentOptions

    Returns Promise<KeyVaultRoleAssignment>

deleteRoleAssignment

  • Deletes role assignments previously created in an Azure Key Vault.

    Example usage:

    const client = new KeyVaultAccessControlClient(url, credentials);
    const roleAssignment = await client.createRoleAssignment("/", "295c179b-9ad3-4117-99cd-b1aa66cf4517");
    const deletedRoleAssignment = const await client.deleteRoleAssignment(roleAssignment.properties.roleScope, roleAssignment.name);
    console.log(deletedRoleAssignment);
    summary

    Deletes an existing role assignment.

    Parameters

    Returns Promise<KeyVaultRoleAssignment>

getRoleAssignment

  • Gets a role assignments previously created in an Azure Key Vault.

    Example usage:

    const client = new KeyVaultAccessControlClient(url, credentials);
    let roleAssignment = await client.createRoleAssignment("/", "295c179b-9ad3-4117-99cd-b1aa66cf4517");
    roleAssignment = const await client.getRoleAssignment(roleAssignment.properties.roleScope, roleAssignment.name);
    console.log(roleAssignment);
    summary

    Gets an existing role assignment.

    Parameters

    Returns Promise<KeyVaultRoleAssignment>

listRoleAssignments

  • Iterates over all of the available role assignments in an Azure Key Vault.

    Example usage:

    let client = new KeyVaultAccessControlClient(url, credentials);
    for await (const roleAssignment of client.listRoleAssignments("/")) {
      console.log("Role assignment: ", roleAssignment);
    }
    summary

    Lists all of the role assignments in a given scope.

    Parameters

    Returns PagedAsyncIterableIterator<KeyVaultRoleAssignment>

listRoleDefinitions

  • Iterates over all of the available role definitions in an Azure Key Vault.

    Example usage:

    let client = new KeyVaultAccessControlClient(url, credentials);
    for await (const roleDefinitions of client.listRoleDefinitions("/")) {
      console.log("Role definition: ", roleDefinitions);
    }
    summary

    Lists all of the role definition in a given scope.

    Parameters

    Returns PagedAsyncIterableIterator<KeyVaultRoleDefinition>

Generated using TypeDoc