Time Series Insights Event Source Iothub
Manages an Azure IoT Time Series Insights IoTHub Event Source.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = new azure.core.ResourceGroup("example", {
name: "example",
location: "West Europe",
});
const exampleIoTHub = new azure.iot.IoTHub("example", {
name: "example",
resourceGroupName: example.name,
location: example.location,
sku: {
name: "B1",
capacity: 1,
},
});
const exampleConsumerGroup = new azure.iot.ConsumerGroup("example", {
name: "example",
iothubName: exampleIoTHub.name,
eventhubEndpointName: "events",
resourceGroupName: example.name,
});
const storage = new azure.storage.Account("storage", {
name: "example",
location: example.location,
resourceGroupName: example.name,
accountTier: "Standard",
accountReplicationType: "LRS",
});
const exampleTimeSeriesInsightsGen2Environment = new azure.iot.TimeSeriesInsightsGen2Environment("example", {
name: "example",
location: example.location,
resourceGroupName: example.name,
skuName: "L1",
idProperties: ["id"],
storage: {
name: storage.name,
key: storage.primaryAccessKey,
},
});
const exampleTimeSeriesInsightsEventSourceIothub = new azure.iot.TimeSeriesInsightsEventSourceIothub("example", {
name: "example",
location: example.location,
environmentId: exampleTimeSeriesInsightsGen2Environment.id,
iothubName: exampleIoTHub.name,
sharedAccessKey: exampleIoTHub.sharedAccessPolicies.apply(sharedAccessPolicies => sharedAccessPolicies[0].primaryKey),
sharedAccessKeyName: exampleIoTHub.sharedAccessPolicies.apply(sharedAccessPolicies => sharedAccessPolicies[0].keyName),
consumerGroupName: exampleConsumerGroup.name,
eventSourceResourceId: exampleIoTHub.id,
});
import pulumi
import pulumi_azure as azure
example = azure.core.ResourceGroup("example",
name="example",
location="West Europe")
example_io_t_hub = azure.iot.IoTHub("example",
name="example",
resource_group_name=example.name,
location=example.location,
sku={
"name": "B1",
"capacity": 1,
})
example_consumer_group = azure.iot.ConsumerGroup("example",
name="example",
iothub_name=example_io_t_hub.name,
eventhub_endpoint_name="events",
resource_group_name=example.name)
storage = azure.storage.Account("storage",
name="example",
location=example.location,
resource_group_name=example.name,
account_tier="Standard",
account_replication_type="LRS")
example_time_series_insights_gen2_environment = azure.iot.TimeSeriesInsightsGen2Environment("example",
name="example",
location=example.location,
resource_group_name=example.name,
sku_name="L1",
id_properties=["id"],
storage={
"name": storage.name,
"key": storage.primary_access_key,
})
example_time_series_insights_event_source_iothub = azure.iot.TimeSeriesInsightsEventSourceIothub("example",
name="example",
location=example.location,
environment_id=example_time_series_insights_gen2_environment.id,
iothub_name=example_io_t_hub.name,
shared_access_key=example_io_t_hub.shared_access_policies[0].primary_key,
shared_access_key_name=example_io_t_hub.shared_access_policies[0].key_name,
consumer_group_name=example_consumer_group.name,
event_source_resource_id=example_io_t_hub.id)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = new Azure.Core.ResourceGroup("example", new()
{
Name = "example",
Location = "West Europe",
});
var exampleIoTHub = new Azure.Iot.IoTHub("example", new()
{
Name = "example",
ResourceGroupName = example.Name,
Location = example.Location,
Sku = new Azure.Iot.Inputs.IoTHubSkuArgs
{
Name = "B1",
Capacity = 1,
},
});
var exampleConsumerGroup = new Azure.Iot.ConsumerGroup("example", new()
{
Name = "example",
IothubName = exampleIoTHub.Name,
EventhubEndpointName = "events",
ResourceGroupName = example.Name,
});
var storage = new Azure.Storage.Account("storage", new()
{
Name = "example",
Location = example.Location,
ResourceGroupName = example.Name,
AccountTier = "Standard",
AccountReplicationType = "LRS",
});
var exampleTimeSeriesInsightsGen2Environment = new Azure.Iot.TimeSeriesInsightsGen2Environment("example", new()
{
Name = "example",
Location = example.Location,
ResourceGroupName = example.Name,
SkuName = "L1",
IdProperties = new[]
{
"id",
},
Storage = new Azure.Iot.Inputs.TimeSeriesInsightsGen2EnvironmentStorageArgs
{
Name = storage.Name,
Key = storage.PrimaryAccessKey,
},
});
var exampleTimeSeriesInsightsEventSourceIothub = new Azure.Iot.TimeSeriesInsightsEventSourceIothub("example", new()
{
Name = "example",
Location = example.Location,
EnvironmentId = exampleTimeSeriesInsightsGen2Environment.Id,
IothubName = exampleIoTHub.Name,
SharedAccessKey = exampleIoTHub.SharedAccessPolicies.Apply(sharedAccessPolicies => sharedAccessPolicies[0].PrimaryKey),
SharedAccessKeyName = exampleIoTHub.SharedAccessPolicies.Apply(sharedAccessPolicies => sharedAccessPolicies[0].KeyName),
ConsumerGroupName = exampleConsumerGroup.Name,
EventSourceResourceId = exampleIoTHub.Id,
});
});
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/iot"
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/storage"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("example"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleIoTHub, err := iot.NewIoTHub(ctx, "example", &iot.IoTHubArgs{
Name: pulumi.String("example"),
ResourceGroupName: example.Name,
Location: example.Location,
Sku: &iot.IoTHubSkuArgs{
Name: pulumi.String("B1"),
Capacity: pulumi.Int(1),
},
})
if err != nil {
return err
}
exampleConsumerGroup, err := iot.NewConsumerGroup(ctx, "example", &iot.ConsumerGroupArgs{
Name: pulumi.String("example"),
IothubName: exampleIoTHub.Name,
EventhubEndpointName: pulumi.String("events"),
ResourceGroupName: example.Name,
})
if err != nil {
return err
}
storage, err := storage.NewAccount(ctx, "storage", &storage.AccountArgs{
Name: pulumi.String("example"),
Location: example.Location,
ResourceGroupName: example.Name,
AccountTier: pulumi.String("Standard"),
AccountReplicationType: pulumi.String("LRS"),
})
if err != nil {
return err
}
exampleTimeSeriesInsightsGen2Environment, err := iot.NewTimeSeriesInsightsGen2Environment(ctx, "example", &iot.TimeSeriesInsightsGen2EnvironmentArgs{
Name: pulumi.String("example"),
Location: example.Location,
ResourceGroupName: example.Name,
SkuName: pulumi.String("L1"),
IdProperties: pulumi.StringArray{
pulumi.String("id"),
},
Storage: &iot.TimeSeriesInsightsGen2EnvironmentStorageArgs{
Name: storage.Name,
Key: storage.PrimaryAccessKey,
},
})
if err != nil {
return err
}
_, err = iot.NewTimeSeriesInsightsEventSourceIothub(ctx, "example", &iot.TimeSeriesInsightsEventSourceIothubArgs{
Name: pulumi.String("example"),
Location: example.Location,
EnvironmentId: exampleTimeSeriesInsightsGen2Environment.ID(),
IothubName: exampleIoTHub.Name,
SharedAccessKey: pulumi.String(exampleIoTHub.SharedAccessPolicies.ApplyT(func(sharedAccessPolicies []iot.IoTHubSharedAccessPolicy) (*string, error) {
return &sharedAccessPolicies[0].PrimaryKey, nil
}).(pulumi.StringPtrOutput)),
SharedAccessKeyName: pulumi.String(exampleIoTHub.SharedAccessPolicies.ApplyT(func(sharedAccessPolicies []iot.IoTHubSharedAccessPolicy) (*string, error) {
return &sharedAccessPolicies[0].KeyName, nil
}).(pulumi.StringPtrOutput)),
ConsumerGroupName: exampleConsumerGroup.Name,
EventSourceResourceId: exampleIoTHub.ID(),
})
if err != nil {
return err
}
return nil
})
}
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.iot.IoTHub;
import com.pulumi.azure.iot.IoTHubArgs;
import com.pulumi.azure.iot.inputs.IoTHubSkuArgs;
import com.pulumi.azure.iot.ConsumerGroup;
import com.pulumi.azure.iot.ConsumerGroupArgs;
import com.pulumi.azure.storage.Account;
import com.pulumi.azure.storage.AccountArgs;
import com.pulumi.azure.iot.TimeSeriesInsightsGen2Environment;
import com.pulumi.azure.iot.TimeSeriesInsightsGen2EnvironmentArgs;
import com.pulumi.azure.iot.inputs.TimeSeriesInsightsGen2EnvironmentStorageArgs;
import com.pulumi.azure.iot.TimeSeriesInsightsEventSourceIothub;
import com.pulumi.azure.iot.TimeSeriesInsightsEventSourceIothubArgs;
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 example = new ResourceGroup("example", ResourceGroupArgs.builder()
.name("example")
.location("West Europe")
.build());
var exampleIoTHub = new IoTHub("exampleIoTHub", IoTHubArgs.builder()
.name("example")
.resourceGroupName(example.name())
.location(example.location())
.sku(IoTHubSkuArgs.builder()
.name("B1")
.capacity("1")
.build())
.build());
var exampleConsumerGroup = new ConsumerGroup("exampleConsumerGroup", ConsumerGroupArgs.builder()
.name("example")
.iothubName(exampleIoTHub.name())
.eventhubEndpointName("events")
.resourceGroupName(example.name())
.build());
var storage = new Account("storage", AccountArgs.builder()
.name("example")
.location(example.location())
.resourceGroupName(example.name())
.accountTier("Standard")
.accountReplicationType("LRS")
.build());
var exampleTimeSeriesInsightsGen2Environment = new TimeSeriesInsightsGen2Environment("exampleTimeSeriesInsightsGen2Environment", TimeSeriesInsightsGen2EnvironmentArgs.builder()
.name("example")
.location(example.location())
.resourceGroupName(example.name())
.skuName("L1")
.idProperties("id")
.storage(TimeSeriesInsightsGen2EnvironmentStorageArgs.builder()
.name(storage.name())
.key(storage.primaryAccessKey())
.build())
.build());
var exampleTimeSeriesInsightsEventSourceIothub = new TimeSeriesInsightsEventSourceIothub("exampleTimeSeriesInsightsEventSourceIothub", TimeSeriesInsightsEventSourceIothubArgs.builder()
.name("example")
.location(example.location())
.environmentId(exampleTimeSeriesInsightsGen2Environment.id())
.iothubName(exampleIoTHub.name())
.sharedAccessKey(exampleIoTHub.sharedAccessPolicies().applyValue(sharedAccessPolicies -> sharedAccessPolicies[0].primaryKey()))
.sharedAccessKeyName(exampleIoTHub.sharedAccessPolicies().applyValue(sharedAccessPolicies -> sharedAccessPolicies[0].keyName()))
.consumerGroupName(exampleConsumerGroup.name())
.eventSourceResourceId(exampleIoTHub.id())
.build());
}
}
resources:
example:
type: azure:core:ResourceGroup
properties:
name: example
location: West Europe
exampleIoTHub:
type: azure:iot:IoTHub
name: example
properties:
name: example
resourceGroupName: ${example.name}
location: ${example.location}
sku:
name: B1
capacity: '1'
exampleConsumerGroup:
type: azure:iot:ConsumerGroup
name: example
properties:
name: example
iothubName: ${exampleIoTHub.name}
eventhubEndpointName: events
resourceGroupName: ${example.name}
storage:
type: azure:storage:Account
properties:
name: example
location: ${example.location}
resourceGroupName: ${example.name}
accountTier: Standard
accountReplicationType: LRS
exampleTimeSeriesInsightsGen2Environment:
type: azure:iot:TimeSeriesInsightsGen2Environment
name: example
properties:
name: example
location: ${example.location}
resourceGroupName: ${example.name}
skuName: L1
idProperties:
- id
storage:
name: ${storage.name}
key: ${storage.primaryAccessKey}
exampleTimeSeriesInsightsEventSourceIothub:
type: azure:iot:TimeSeriesInsightsEventSourceIothub
name: example
properties:
name: example
location: ${example.location}
environmentId: ${exampleTimeSeriesInsightsGen2Environment.id}
iothubName: ${exampleIoTHub.name}
sharedAccessKey: ${exampleIoTHub.sharedAccessPolicies[0].primaryKey}
sharedAccessKeyName: ${exampleIoTHub.sharedAccessPolicies[0].keyName}
consumerGroupName: ${exampleConsumerGroup.name}
eventSourceResourceId: ${exampleIoTHub.id}
Import
Azure IoT Time Series Insights IoTHub Event Source can be imported using the resource id
, e.g.
$ pulumi import azure:iot/timeSeriesInsightsEventSourceIothub:TimeSeriesInsightsEventSourceIothub example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example/providers/Microsoft.TimeSeriesInsights/environments/environment1/eventSources/example
Properties
Specifies the name of the IotHub Consumer Group that holds the partitions from which events will be read.
Specifies the id of the IoT Time Series Insights Environment that the Event Source should be associated with. Changing this forces a new resource to created.
Specifies the resource id where events will be coming from.
Specifies the name of the IotHub which will be associated with this resource.
Specifies the value of the Shared Access Policy key that grants the Time Series Insights service read access to the IotHub.
Specifies the name of the Shared Access key that grants the Event Source access to the IotHub.
Specifies the value that will be used as the event source's timestamp. This value defaults to the event creation time.