We recommend using Azure Native.
Azure Classic v5.81.0 published on Monday, Jun 24, 2024 by Pulumi
azure.eventhub.getSas
Explore with Pulumi AI
Use this data source to obtain a Shared Access Signature (SAS Token) for an existing Event Hub.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const exampleResourceGroup = new azure.core.ResourceGroup("example", {
name: "example-resources",
location: "West Europe",
});
const exampleEventHubNamespace = new azure.eventhub.EventHubNamespace("example", {
name: "example-ehn",
location: exampleResourceGroup.location,
resourceGroupName: exampleResourceGroup.name,
sku: "Basic",
});
const exampleEventHub = new azure.eventhub.EventHub("example", {
name: "example-eh",
namespaceName: exampleEventHubNamespace.name,
resourceGroupName: exampleResourceGroup.name,
partitionCount: 1,
messageRetention: 1,
});
const exampleAuthorizationRule = new azure.eventhub.AuthorizationRule("example", {
name: "example-ehar",
namespaceName: exampleEventHubNamespace.name,
eventhubName: exampleEventHub.name,
resourceGroupName: exampleResourceGroup.name,
listen: true,
send: true,
manage: true,
});
const example = azure.eventhub.getAuthorizationRuleOutput({
name: exampleAuthorizationRule.name,
namespaceName: exampleEventHubNamespace.name,
eventhubName: exampleEventHub.name,
resourceGroupName: exampleResourceGroup.name,
});
const exampleGetSas = example.apply(example => azure.eventhub.getSasOutput({
connectionString: example.primaryConnectionString,
expiry: "2023-06-23T00:00:00Z",
}));
import pulumi
import pulumi_azure as azure
example_resource_group = azure.core.ResourceGroup("example",
name="example-resources",
location="West Europe")
example_event_hub_namespace = azure.eventhub.EventHubNamespace("example",
name="example-ehn",
location=example_resource_group.location,
resource_group_name=example_resource_group.name,
sku="Basic")
example_event_hub = azure.eventhub.EventHub("example",
name="example-eh",
namespace_name=example_event_hub_namespace.name,
resource_group_name=example_resource_group.name,
partition_count=1,
message_retention=1)
example_authorization_rule = azure.eventhub.AuthorizationRule("example",
name="example-ehar",
namespace_name=example_event_hub_namespace.name,
eventhub_name=example_event_hub.name,
resource_group_name=example_resource_group.name,
listen=True,
send=True,
manage=True)
example = azure.eventhub.get_authorization_rule_output(name=example_authorization_rule.name,
namespace_name=example_event_hub_namespace.name,
eventhub_name=example_event_hub.name,
resource_group_name=example_resource_group.name)
example_get_sas = example.apply(lambda example: azure.eventhub.get_sas_output(connection_string=example.primary_connection_string,
expiry="2023-06-23T00:00:00Z"))
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/eventhub"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleResourceGroup, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("example-resources"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleEventHubNamespace, err := eventhub.NewEventHubNamespace(ctx, "example", &eventhub.EventHubNamespaceArgs{
Name: pulumi.String("example-ehn"),
Location: exampleResourceGroup.Location,
ResourceGroupName: exampleResourceGroup.Name,
Sku: pulumi.String("Basic"),
})
if err != nil {
return err
}
exampleEventHub, err := eventhub.NewEventHub(ctx, "example", &eventhub.EventHubArgs{
Name: pulumi.String("example-eh"),
NamespaceName: exampleEventHubNamespace.Name,
ResourceGroupName: exampleResourceGroup.Name,
PartitionCount: pulumi.Int(1),
MessageRetention: pulumi.Int(1),
})
if err != nil {
return err
}
exampleAuthorizationRule, err := eventhub.NewAuthorizationRule(ctx, "example", &eventhub.AuthorizationRuleArgs{
Name: pulumi.String("example-ehar"),
NamespaceName: exampleEventHubNamespace.Name,
EventhubName: exampleEventHub.Name,
ResourceGroupName: exampleResourceGroup.Name,
Listen: pulumi.Bool(true),
Send: pulumi.Bool(true),
Manage: pulumi.Bool(true),
})
if err != nil {
return err
}
example := eventhub.LookupAuthorizationRuleOutput(ctx, eventhub.GetAuthorizationRuleOutputArgs{
Name: exampleAuthorizationRule.Name,
NamespaceName: exampleEventHubNamespace.Name,
EventhubName: exampleEventHub.Name,
ResourceGroupName: exampleResourceGroup.Name,
}, nil)
_ = example.ApplyT(func(example eventhub.GetAuthorizationRuleResult) (eventhub.GetSasResult, error) {
return eventhub.GetSasOutput(ctx, eventhub.GetSasOutputArgs{
ConnectionString: example.PrimaryConnectionString,
Expiry: "2023-06-23T00:00:00Z",
}, nil), nil
}).(eventhub.GetSasResultOutput)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var exampleResourceGroup = new Azure.Core.ResourceGroup("example", new()
{
Name = "example-resources",
Location = "West Europe",
});
var exampleEventHubNamespace = new Azure.EventHub.EventHubNamespace("example", new()
{
Name = "example-ehn",
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
Sku = "Basic",
});
var exampleEventHub = new Azure.EventHub.EventHub("example", new()
{
Name = "example-eh",
NamespaceName = exampleEventHubNamespace.Name,
ResourceGroupName = exampleResourceGroup.Name,
PartitionCount = 1,
MessageRetention = 1,
});
var exampleAuthorizationRule = new Azure.EventHub.AuthorizationRule("example", new()
{
Name = "example-ehar",
NamespaceName = exampleEventHubNamespace.Name,
EventhubName = exampleEventHub.Name,
ResourceGroupName = exampleResourceGroup.Name,
Listen = true,
Send = true,
Manage = true,
});
var example = Azure.EventHub.GetAuthorizationRule.Invoke(new()
{
Name = exampleAuthorizationRule.Name,
NamespaceName = exampleEventHubNamespace.Name,
EventhubName = exampleEventHub.Name,
ResourceGroupName = exampleResourceGroup.Name,
});
var exampleGetSas = Azure.EventHub.GetSas.Invoke(new()
{
ConnectionString = example.Apply(getAuthorizationRuleResult => getAuthorizationRuleResult.PrimaryConnectionString),
Expiry = "2023-06-23T00:00:00Z",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.eventhub.EventHubNamespace;
import com.pulumi.azure.eventhub.EventHubNamespaceArgs;
import com.pulumi.azure.eventhub.EventHub;
import com.pulumi.azure.eventhub.EventHubArgs;
import com.pulumi.azure.eventhub.AuthorizationRule;
import com.pulumi.azure.eventhub.AuthorizationRuleArgs;
import com.pulumi.azure.eventhub.EventhubFunctions;
import com.pulumi.azure.eventhub.inputs.GetAuthorizationRuleArgs;
import com.pulumi.azure.eventhub.inputs.GetSasArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()
.name("example-resources")
.location("West Europe")
.build());
var exampleEventHubNamespace = new EventHubNamespace("exampleEventHubNamespace", EventHubNamespaceArgs.builder()
.name("example-ehn")
.location(exampleResourceGroup.location())
.resourceGroupName(exampleResourceGroup.name())
.sku("Basic")
.build());
var exampleEventHub = new EventHub("exampleEventHub", EventHubArgs.builder()
.name("example-eh")
.namespaceName(exampleEventHubNamespace.name())
.resourceGroupName(exampleResourceGroup.name())
.partitionCount(1)
.messageRetention(1)
.build());
var exampleAuthorizationRule = new AuthorizationRule("exampleAuthorizationRule", AuthorizationRuleArgs.builder()
.name("example-ehar")
.namespaceName(exampleEventHubNamespace.name())
.eventhubName(exampleEventHub.name())
.resourceGroupName(exampleResourceGroup.name())
.listen(true)
.send(true)
.manage(true)
.build());
final var example = EventhubFunctions.getAuthorizationRule(GetAuthorizationRuleArgs.builder()
.name(exampleAuthorizationRule.name())
.namespaceName(exampleEventHubNamespace.name())
.eventhubName(exampleEventHub.name())
.resourceGroupName(exampleResourceGroup.name())
.build());
final var exampleGetSas = EventhubFunctions.getSas(GetSasArgs.builder()
.connectionString(example.applyValue(getAuthorizationRuleResult -> getAuthorizationRuleResult).applyValue(example -> example.applyValue(getAuthorizationRuleResult -> getAuthorizationRuleResult.primaryConnectionString())))
.expiry("2023-06-23T00:00:00Z")
.build());
}
}
resources:
exampleResourceGroup:
type: azure:core:ResourceGroup
name: example
properties:
name: example-resources
location: West Europe
exampleEventHubNamespace:
type: azure:eventhub:EventHubNamespace
name: example
properties:
name: example-ehn
location: ${exampleResourceGroup.location}
resourceGroupName: ${exampleResourceGroup.name}
sku: Basic
exampleEventHub:
type: azure:eventhub:EventHub
name: example
properties:
name: example-eh
namespaceName: ${exampleEventHubNamespace.name}
resourceGroupName: ${exampleResourceGroup.name}
partitionCount: 1
messageRetention: 1
exampleAuthorizationRule:
type: azure:eventhub:AuthorizationRule
name: example
properties:
name: example-ehar
namespaceName: ${exampleEventHubNamespace.name}
eventhubName: ${exampleEventHub.name}
resourceGroupName: ${exampleResourceGroup.name}
listen: true
send: true
manage: true
variables:
example:
fn::invoke:
Function: azure:eventhub:getAuthorizationRule
Arguments:
name: ${exampleAuthorizationRule.name}
namespaceName: ${exampleEventHubNamespace.name}
eventhubName: ${exampleEventHub.name}
resourceGroupName: ${exampleResourceGroup.name}
exampleGetSas:
fn::invoke:
Function: azure:eventhub:getSas
Arguments:
connectionString: ${example.primaryConnectionString}
expiry: 2023-06-23T00:00:00Z
Using getSas
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getSas(args: GetSasArgs, opts?: InvokeOptions): Promise<GetSasResult>
function getSasOutput(args: GetSasOutputArgs, opts?: InvokeOptions): Output<GetSasResult>
def get_sas(connection_string: Optional[str] = None,
expiry: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetSasResult
def get_sas_output(connection_string: Optional[pulumi.Input[str]] = None,
expiry: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetSasResult]
func GetSas(ctx *Context, args *GetSasArgs, opts ...InvokeOption) (*GetSasResult, error)
func GetSasOutput(ctx *Context, args *GetSasOutputArgs, opts ...InvokeOption) GetSasResultOutput
> Note: This function is named GetSas
in the Go SDK.
public static class GetSas
{
public static Task<GetSasResult> InvokeAsync(GetSasArgs args, InvokeOptions? opts = null)
public static Output<GetSasResult> Invoke(GetSasInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetSasResult> getSas(GetSasArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: azure:eventhub/getSas:getSas
arguments:
# arguments dictionary
The following arguments are supported:
- Connection
String string - The connection string for the Event Hub to which this SAS applies.
- Expiry string
- The expiration time and date of this SAS. Must be a valid ISO-8601 format time/date string.
- Connection
String string - The connection string for the Event Hub to which this SAS applies.
- Expiry string
- The expiration time and date of this SAS. Must be a valid ISO-8601 format time/date string.
- connection
String String - The connection string for the Event Hub to which this SAS applies.
- expiry String
- The expiration time and date of this SAS. Must be a valid ISO-8601 format time/date string.
- connection
String string - The connection string for the Event Hub to which this SAS applies.
- expiry string
- The expiration time and date of this SAS. Must be a valid ISO-8601 format time/date string.
- connection_
string str - The connection string for the Event Hub to which this SAS applies.
- expiry str
- The expiration time and date of this SAS. Must be a valid ISO-8601 format time/date string.
- connection
String String - The connection string for the Event Hub to which this SAS applies.
- expiry String
- The expiration time and date of this SAS. Must be a valid ISO-8601 format time/date string.
getSas Result
The following output properties are available:
- Connection
String string - Expiry string
- Id string
- The provider-assigned unique ID for this managed resource.
- Sas string
- The computed Event Hub Shared Access Signature (SAS).
- Connection
String string - Expiry string
- Id string
- The provider-assigned unique ID for this managed resource.
- Sas string
- The computed Event Hub Shared Access Signature (SAS).
- connection
String String - expiry String
- id String
- The provider-assigned unique ID for this managed resource.
- sas String
- The computed Event Hub Shared Access Signature (SAS).
- connection
String string - expiry string
- id string
- The provider-assigned unique ID for this managed resource.
- sas string
- The computed Event Hub Shared Access Signature (SAS).
- connection_
string str - expiry str
- id str
- The provider-assigned unique ID for this managed resource.
- sas str
- The computed Event Hub Shared Access Signature (SAS).
- connection
String String - expiry String
- id String
- The provider-assigned unique ID for this managed resource.
- sas String
- The computed Event Hub Shared Access Signature (SAS).
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurerm
Terraform Provider.