User Story 60501: 101-stream-analytics-job (#216)

* Part of POC to test generating sample code and articles using OpenAI.
This commit is contained in:
Tom Archer 2023-04-21 19:37:21 -07:00 committed by GitHub
parent 817c23d293
commit 1c2b68b884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 92 additions and 0 deletions

View File

@ -0,0 +1,34 @@
resource "random_pet" "rg_name" {
prefix = "rg"
}
resource "azurerm_resource_group" "rg" {
name = random_pet.rg_name.id
location = var.resource_group_location
}
resource "random_pet" "stream_analytics_job_name" {
prefix = "job"
}
resource "azurerm_stream_analytics_job" "job" {
name = random_pet.stream_analytics_job_name.id
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
streaming_units = var.number_of_streaming_units
events_out_of_order_max_delay_in_seconds = 0
events_late_arrival_max_delay_in_seconds = 5
data_locale = "en-US"
events_out_of_order_policy = "Adjust"
output_error_policy = "Stop"
transformation_query = <<QUERY
SELECT
*
INTO
[YourOutputAlias]
FROM
[YourInputAlias]
QUERY
}

View File

@ -0,0 +1,7 @@
output "resource_group_name" {
value = azurerm_resource_group.rg.name
}
output "stream_analytics_job_name" {
value = azurerm_stream_analytics_job.job.name
}

View File

@ -0,0 +1,16 @@
terraform {
required_version = ">=1.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
}
random = {
source = "hashicorp/random"
version = "~>3.0"
}
}
}
provider "azurerm" {
features {}
}

View File

@ -0,0 +1,20 @@
# Azure Stream Analytics Job
This template deploys an Azure Stream Analytics Job.
## Terraform resource types
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
- [azurerm_stream_analytics_job](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/stream_analytics_job)
## Variables
| Name | Description | Default |
|-|-|-|
| `resource_group_location` | Location of the resource group. | eastus |
| `number_of_streaming_units` | Number of Streaming Units. | 1 |
## Example
To see how to run this example, see [Create an Azure Stream Analytics job using Terraform](https://learn.microsoft.com/azure/stream-analytics/quick-create-terraform)

View File

@ -0,0 +1,15 @@
variable "resource_group_location" {
type = string
description = "Location for the resources."
default = "eastus"
}
variable "number_of_streaming_units" {
type = number
description = "Number of streaming units."
default = 1
validation {
condition = contains([1, 3, 6, 12, 18, 24, 30, 36, 42, 48], var.number_of_streaming_units)
error_message = "Invalid value for: number_of_streaming_units. The value should be one of the following: 1, 3, 6, 12, 18, 24, 30, 36, 42, 48."
}
}