We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
Manages a Customer Managed Key for a EventHub Namespace.
!> Note: In 2.x versions of the Azure Provider during deletion this resource will delete and recreate the parent EventHub Namespace which may involve data loss as it’s not possible to remove the Customer Managed Key from the EventHub Namespace once it’s been added. Version 3.0 of the Azure Provider will change this so that the Delete operation is a noop, requiring the parent EventHub Namespace is deleted/recreated to remove the Customer Managed Key.
Example Usage
using Pulumi;
using Azure = Pulumi.Azure;
class MyStack : Stack
{
public MyStack()
{
var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new Azure.Core.ResourceGroupArgs
{
Location = "West Europe",
});
var exampleCluster = new Azure.EventHub.Cluster("exampleCluster", new Azure.EventHub.ClusterArgs
{
ResourceGroupName = exampleResourceGroup.Name,
Location = exampleResourceGroup.Location,
SkuName = "Dedicated_1",
});
var exampleEventHubNamespace = new Azure.EventHub.EventHubNamespace("exampleEventHubNamespace", new Azure.EventHub.EventHubNamespaceArgs
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
Sku = "Standard",
DedicatedClusterId = exampleCluster.Id,
Identity = new Azure.EventHub.Inputs.EventHubNamespaceIdentityArgs
{
Type = "SystemAssigned",
},
});
var current = Output.Create(Azure.Core.GetClientConfig.InvokeAsync());
var exampleKeyVault = new Azure.KeyVault.KeyVault("exampleKeyVault", new Azure.KeyVault.KeyVaultArgs
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
TenantId = current.Apply(current => current.TenantId),
SkuName = "standard",
SoftDeleteEnabled = true,
PurgeProtectionEnabled = true,
});
var exampleAccessPolicy = new Azure.KeyVault.AccessPolicy("exampleAccessPolicy", new Azure.KeyVault.AccessPolicyArgs
{
KeyVaultId = exampleKeyVault.Id,
TenantId = exampleEventHubNamespace.Identity.Apply(identity => identity?.TenantId),
ObjectId = exampleEventHubNamespace.Identity.Apply(identity => identity?.PrincipalId),
KeyPermissions =
{
"get",
"unwrapkey",
"wrapkey",
},
});
var example2 = new Azure.KeyVault.AccessPolicy("example2", new Azure.KeyVault.AccessPolicyArgs
{
KeyVaultId = exampleKeyVault.Id,
TenantId = current.Apply(current => current.TenantId),
ObjectId = current.Apply(current => current.ObjectId),
KeyPermissions =
{
"create",
"delete",
"get",
"list",
"purge",
"recover",
},
});
var exampleKey = new Azure.KeyVault.Key("exampleKey", new Azure.KeyVault.KeyArgs
{
KeyVaultId = exampleKeyVault.Id,
KeyType = "RSA",
KeySize = 2048,
KeyOpts =
{
"decrypt",
"encrypt",
"sign",
"unwrapKey",
"verify",
"wrapKey",
},
}, new CustomResourceOptions
{
DependsOn =
{
exampleAccessPolicy,
example2,
},
});
var exampleNamespaceCustomerManagedKey = new Azure.EventHub.NamespaceCustomerManagedKey("exampleNamespaceCustomerManagedKey", new Azure.EventHub.NamespaceCustomerManagedKeyArgs
{
EventhubNamespaceId = exampleEventHubNamespace.Id,
KeyVaultKeyIds =
{
exampleKey.Id,
},
});
}
}
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/eventhub"
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/keyvault"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleCluster, err := eventhub.NewCluster(ctx, "exampleCluster", &eventhub.ClusterArgs{
ResourceGroupName: exampleResourceGroup.Name,
Location: exampleResourceGroup.Location,
SkuName: pulumi.String("Dedicated_1"),
})
if err != nil {
return err
}
exampleEventHubNamespace, err := eventhub.NewEventHubNamespace(ctx, "exampleEventHubNamespace", &eventhub.EventHubNamespaceArgs{
Location: exampleResourceGroup.Location,
ResourceGroupName: exampleResourceGroup.Name,
Sku: pulumi.String("Standard"),
DedicatedClusterId: exampleCluster.ID(),
Identity: &eventhub.EventHubNamespaceIdentityArgs{
Type: pulumi.String("SystemAssigned"),
},
})
if err != nil {
return err
}
current, err := core.GetClientConfig(ctx, nil, nil)
if err != nil {
return err
}
exampleKeyVault, err := keyvault.NewKeyVault(ctx, "exampleKeyVault", &keyvault.KeyVaultArgs{
Location: exampleResourceGroup.Location,
ResourceGroupName: exampleResourceGroup.Name,
TenantId: pulumi.String(current.TenantId),
SkuName: pulumi.String("standard"),
SoftDeleteEnabled: pulumi.Bool(true),
PurgeProtectionEnabled: pulumi.Bool(true),
})
if err != nil {
return err
}
exampleAccessPolicy, err := keyvault.NewAccessPolicy(ctx, "exampleAccessPolicy", &keyvault.AccessPolicyArgs{
KeyVaultId: exampleKeyVault.ID(),
TenantId: exampleEventHubNamespace.Identity.ApplyT(func(identity eventhub.EventHubNamespaceIdentity) (string, error) {
return identity.TenantId, nil
}).(pulumi.StringOutput),
ObjectId: exampleEventHubNamespace.Identity.ApplyT(func(identity eventhub.EventHubNamespaceIdentity) (string, error) {
return identity.PrincipalId, nil
}).(pulumi.StringOutput),
KeyPermissions: pulumi.StringArray{
pulumi.String("get"),
pulumi.String("unwrapkey"),
pulumi.String("wrapkey"),
},
})
if err != nil {
return err
}
example2, err := keyvault.NewAccessPolicy(ctx, "example2", &keyvault.AccessPolicyArgs{
KeyVaultId: exampleKeyVault.ID(),
TenantId: pulumi.String(current.TenantId),
ObjectId: pulumi.String(current.ObjectId),
KeyPermissions: pulumi.StringArray{
pulumi.String("create"),
pulumi.String("delete"),
pulumi.String("get"),
pulumi.String("list"),
pulumi.String("purge"),
pulumi.String("recover"),
},
})
if err != nil {
return err
}
exampleKey, err := keyvault.NewKey(ctx, "exampleKey", &keyvault.KeyArgs{
KeyVaultId: exampleKeyVault.ID(),
KeyType: pulumi.String("RSA"),
KeySize: pulumi.Int(2048),
KeyOpts: pulumi.StringArray{
pulumi.String("decrypt"),
pulumi.String("encrypt"),
pulumi.String("sign"),
pulumi.String("unwrapKey"),
pulumi.String("verify"),
pulumi.String("wrapKey"),
},
}, pulumi.DependsOn([]pulumi.Resource{
exampleAccessPolicy,
example2,
}))
if err != nil {
return err
}
_, err = eventhub.NewNamespaceCustomerManagedKey(ctx, "exampleNamespaceCustomerManagedKey", &eventhub.NamespaceCustomerManagedKeyArgs{
EventhubNamespaceId: exampleEventHubNamespace.ID(),
KeyVaultKeyIds: pulumi.StringArray{
exampleKey.ID(),
},
})
if err != nil {
return err
}
return nil
})
}
Example coming soon!
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
const exampleCluster = new azure.eventhub.Cluster("exampleCluster", {
resourceGroupName: exampleResourceGroup.name,
location: exampleResourceGroup.location,
skuName: "Dedicated_1",
});
const exampleEventHubNamespace = new azure.eventhub.EventHubNamespace("exampleEventHubNamespace", {
location: exampleResourceGroup.location,
resourceGroupName: exampleResourceGroup.name,
sku: "Standard",
dedicatedClusterId: exampleCluster.id,
identity: {
type: "SystemAssigned",
},
});
const current = azure.core.getClientConfig({});
const exampleKeyVault = new azure.keyvault.KeyVault("exampleKeyVault", {
location: exampleResourceGroup.location,
resourceGroupName: exampleResourceGroup.name,
tenantId: current.then(current => current.tenantId),
skuName: "standard",
softDeleteEnabled: true,
purgeProtectionEnabled: true,
});
const exampleAccessPolicy = new azure.keyvault.AccessPolicy("exampleAccessPolicy", {
keyVaultId: exampleKeyVault.id,
tenantId: exampleEventHubNamespace.identity.apply(identity => identity?.tenantId),
objectId: exampleEventHubNamespace.identity.apply(identity => identity?.principalId),
keyPermissions: [
"get",
"unwrapkey",
"wrapkey",
],
});
const example2 = new azure.keyvault.AccessPolicy("example2", {
keyVaultId: exampleKeyVault.id,
tenantId: current.then(current => current.tenantId),
objectId: current.then(current => current.objectId),
keyPermissions: [
"create",
"delete",
"get",
"list",
"purge",
"recover",
],
});
const exampleKey = new azure.keyvault.Key("exampleKey", {
keyVaultId: exampleKeyVault.id,
keyType: "RSA",
keySize: 2048,
keyOpts: [
"decrypt",
"encrypt",
"sign",
"unwrapKey",
"verify",
"wrapKey",
],
}, {
dependsOn: [
exampleAccessPolicy,
example2,
],
});
const exampleNamespaceCustomerManagedKey = new azure.eventhub.NamespaceCustomerManagedKey("exampleNamespaceCustomerManagedKey", {
eventhubNamespaceId: exampleEventHubNamespace.id,
keyVaultKeyIds: [exampleKey.id],
});
import pulumi
import pulumi_azure as azure
example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_cluster = azure.eventhub.Cluster("exampleCluster",
resource_group_name=example_resource_group.name,
location=example_resource_group.location,
sku_name="Dedicated_1")
example_event_hub_namespace = azure.eventhub.EventHubNamespace("exampleEventHubNamespace",
location=example_resource_group.location,
resource_group_name=example_resource_group.name,
sku="Standard",
dedicated_cluster_id=example_cluster.id,
identity=azure.eventhub.EventHubNamespaceIdentityArgs(
type="SystemAssigned",
))
current = azure.core.get_client_config()
example_key_vault = azure.keyvault.KeyVault("exampleKeyVault",
location=example_resource_group.location,
resource_group_name=example_resource_group.name,
tenant_id=current.tenant_id,
sku_name="standard",
soft_delete_enabled=True,
purge_protection_enabled=True)
example_access_policy = azure.keyvault.AccessPolicy("exampleAccessPolicy",
key_vault_id=example_key_vault.id,
tenant_id=example_event_hub_namespace.identity.tenant_id,
object_id=example_event_hub_namespace.identity.principal_id,
key_permissions=[
"get",
"unwrapkey",
"wrapkey",
])
example2 = azure.keyvault.AccessPolicy("example2",
key_vault_id=example_key_vault.id,
tenant_id=current.tenant_id,
object_id=current.object_id,
key_permissions=[
"create",
"delete",
"get",
"list",
"purge",
"recover",
])
example_key = azure.keyvault.Key("exampleKey",
key_vault_id=example_key_vault.id,
key_type="RSA",
key_size=2048,
key_opts=[
"decrypt",
"encrypt",
"sign",
"unwrapKey",
"verify",
"wrapKey",
],
opts=pulumi.ResourceOptions(depends_on=[
example_access_policy,
example2,
]))
example_namespace_customer_managed_key = azure.eventhub.NamespaceCustomerManagedKey("exampleNamespaceCustomerManagedKey",
eventhub_namespace_id=example_event_hub_namespace.id,
key_vault_key_ids=[example_key.id])
Example coming soon!
Create NamespaceCustomerManagedKey Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new NamespaceCustomerManagedKey(name: string, args: NamespaceCustomerManagedKeyArgs, opts?: CustomResourceOptions);@overload
def NamespaceCustomerManagedKey(resource_name: str,
args: NamespaceCustomerManagedKeyArgs,
opts: Optional[ResourceOptions] = None)
@overload
def NamespaceCustomerManagedKey(resource_name: str,
opts: Optional[ResourceOptions] = None,
eventhub_namespace_id: Optional[str] = None,
key_vault_key_ids: Optional[Sequence[str]] = None)func NewNamespaceCustomerManagedKey(ctx *Context, name string, args NamespaceCustomerManagedKeyArgs, opts ...ResourceOption) (*NamespaceCustomerManagedKey, error)public NamespaceCustomerManagedKey(string name, NamespaceCustomerManagedKeyArgs args, CustomResourceOptions? opts = null)
public NamespaceCustomerManagedKey(String name, NamespaceCustomerManagedKeyArgs args)
public NamespaceCustomerManagedKey(String name, NamespaceCustomerManagedKeyArgs args, CustomResourceOptions options)
type: azure:eventhub:NamespaceCustomerManagedKey
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args NamespaceCustomerManagedKeyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args NamespaceCustomerManagedKeyArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args NamespaceCustomerManagedKeyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args NamespaceCustomerManagedKeyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args NamespaceCustomerManagedKeyArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var namespaceCustomerManagedKeyResource = new Azure.EventHub.NamespaceCustomerManagedKey("namespaceCustomerManagedKeyResource", new()
{
EventhubNamespaceId = "string",
KeyVaultKeyIds = new[]
{
"string",
},
});
example, err := eventhub.NewNamespaceCustomerManagedKey(ctx, "namespaceCustomerManagedKeyResource", &eventhub.NamespaceCustomerManagedKeyArgs{
EventhubNamespaceId: pulumi.String("string"),
KeyVaultKeyIds: pulumi.StringArray{
pulumi.String("string"),
},
})
var namespaceCustomerManagedKeyResource = new NamespaceCustomerManagedKey("namespaceCustomerManagedKeyResource", NamespaceCustomerManagedKeyArgs.builder()
.eventhubNamespaceId("string")
.keyVaultKeyIds("string")
.build());
namespace_customer_managed_key_resource = azure.eventhub.NamespaceCustomerManagedKey("namespaceCustomerManagedKeyResource",
eventhub_namespace_id="string",
key_vault_key_ids=["string"])
const namespaceCustomerManagedKeyResource = new azure.eventhub.NamespaceCustomerManagedKey("namespaceCustomerManagedKeyResource", {
eventhubNamespaceId: "string",
keyVaultKeyIds: ["string"],
});
type: azure:eventhub:NamespaceCustomerManagedKey
properties:
eventhubNamespaceId: string
keyVaultKeyIds:
- string
NamespaceCustomerManagedKey Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The NamespaceCustomerManagedKey resource accepts the following input properties:
- Eventhub
Namespace stringId - The ID of the EventHub Namespace. Changing this forces a new resource to be created.
- Key
Vault List<string>Key Ids - The list of keys of Key Vault.
- Eventhub
Namespace stringId - The ID of the EventHub Namespace. Changing this forces a new resource to be created.
- Key
Vault []stringKey Ids - The list of keys of Key Vault.
- eventhub
Namespace StringId - The ID of the EventHub Namespace. Changing this forces a new resource to be created.
- key
Vault List<String>Key Ids - The list of keys of Key Vault.
- eventhub
Namespace stringId - The ID of the EventHub Namespace. Changing this forces a new resource to be created.
- key
Vault string[]Key Ids - The list of keys of Key Vault.
- eventhub_
namespace_ strid - The ID of the EventHub Namespace. Changing this forces a new resource to be created.
- key_
vault_ Sequence[str]key_ ids - The list of keys of Key Vault.
- eventhub
Namespace StringId - The ID of the EventHub Namespace. Changing this forces a new resource to be created.
- key
Vault List<String>Key Ids - The list of keys of Key Vault.
Outputs
All input properties are implicitly available as output properties. Additionally, the NamespaceCustomerManagedKey resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing NamespaceCustomerManagedKey Resource
Get an existing NamespaceCustomerManagedKey resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: NamespaceCustomerManagedKeyState, opts?: CustomResourceOptions): NamespaceCustomerManagedKey@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
eventhub_namespace_id: Optional[str] = None,
key_vault_key_ids: Optional[Sequence[str]] = None) -> NamespaceCustomerManagedKeyfunc GetNamespaceCustomerManagedKey(ctx *Context, name string, id IDInput, state *NamespaceCustomerManagedKeyState, opts ...ResourceOption) (*NamespaceCustomerManagedKey, error)public static NamespaceCustomerManagedKey Get(string name, Input<string> id, NamespaceCustomerManagedKeyState? state, CustomResourceOptions? opts = null)public static NamespaceCustomerManagedKey get(String name, Output<String> id, NamespaceCustomerManagedKeyState state, CustomResourceOptions options)resources: _: type: azure:eventhub:NamespaceCustomerManagedKey get: id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Eventhub
Namespace stringId - The ID of the EventHub Namespace. Changing this forces a new resource to be created.
- Key
Vault List<string>Key Ids - The list of keys of Key Vault.
- Eventhub
Namespace stringId - The ID of the EventHub Namespace. Changing this forces a new resource to be created.
- Key
Vault []stringKey Ids - The list of keys of Key Vault.
- eventhub
Namespace StringId - The ID of the EventHub Namespace. Changing this forces a new resource to be created.
- key
Vault List<String>Key Ids - The list of keys of Key Vault.
- eventhub
Namespace stringId - The ID of the EventHub Namespace. Changing this forces a new resource to be created.
- key
Vault string[]Key Ids - The list of keys of Key Vault.
- eventhub_
namespace_ strid - The ID of the EventHub Namespace. Changing this forces a new resource to be created.
- key_
vault_ Sequence[str]key_ ids - The list of keys of Key Vault.
- eventhub
Namespace StringId - The ID of the EventHub Namespace. Changing this forces a new resource to be created.
- key
Vault List<String>Key Ids - The list of keys of Key Vault.
Import
Customer Managed Keys for a EventHub Namespace can be imported using the resource id, e.g.
$ pulumi import azure:eventhub/namespaceCustomerManagedKey:NamespaceCustomerManagedKey example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.EventHub/namespaces/namespace1
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurermTerraform Provider.
We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
