Skip to content

Commit b987d32

Browse files
committed
media AI video indexer
1 parent 4697d11 commit b987d32

9 files changed

Lines changed: 254 additions & 1 deletion

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
**/.terraform/*
33
**/.terraform
44

5+
# Terraform provider schema export files (generated)
6+
**/.terraform-provider-schema.json
7+
58
# .tfstate files
69
*.tfstate
710
*.tfstate.*

11_media-services/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Last updated: 2026-02-09
1515
## Templates
1616

1717
- [cdn](./cdn)
18+
- [ai-video-indexer](./ai-video-indexer)
1819

1920
<!-- START BADGE -->
2021
<div align="center">
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Terraform Template: <br/> Media Services (retired) → Azure AI Video Indexer (ARM-based via AzAPI)
2+
3+
Costa Rica
4+
5+
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
6+
[brown9804](https://github.com/brown9804)
7+
8+
Last updated: 2026-02-10
9+
10+
------------------------------------------
11+
12+
> This template deploys an **Azure AI Video Indexer** account (ARM-based) plus its required **Storage Account**, and grants the Video Indexer managed identity the **Storage Blob Data Contributor** role on the storage account.
13+
14+
> [!IMPORTANT]
15+
> **Azure Media Services (AMS) is retired** and Microsoft **blocks creation of new AMS accounts in all Azure regions**. This template uses Azure AI Video Indexer as the supported replacement for video/audio analysis workflows, and uses the `azapi` provider to deploy `Microsoft.VideoIndexer/accounts@2024-01-01`.
16+
17+
## File Descriptions
18+
19+
- **main.tf**: Creates the Resource Group, Storage Account, Azure AI Video Indexer account (via `azapi_resource`), and role assignment.
20+
- **variables.tf**: Defines the input variables.
21+
- **provider.tf**: Configures the Azure providers (uses Azure CLI auth context).
22+
- **terraform.tfvars**: Example values.
23+
- **outputs.tf**: Exposes resource IDs and the Video Indexer principal ID.
24+
25+
## Variables
26+
27+
| Variable Name | Description | Type | Example Value |
28+
| --- | --- | --- | --- |
29+
| `resource_group_name` | The name of the resource group to create. | string | `"rg-media-services-dev"` |
30+
| `location` | Azure region for deployment. | string | `"East US"` |
31+
| `video_indexer_account_name` | Azure AI Video Indexer account name. | string | `"vi-media-dev-001"` |
32+
| `storage_account_name` | Storage account name (globally unique). | string | `"stmediadev001abc"` |
33+
| `tags` | Tags applied to supported resources. | map(string) | `{ env = "dev" }` |
34+
35+
## Usage
36+
37+
1. Authenticate:
38+
39+
```sh
40+
az login
41+
```
42+
43+
2. (Optional) Select subscription:
44+
45+
```sh
46+
az account set --subscription "<subscription-id-or-name>"
47+
```
48+
49+
3. Initialize:
50+
51+
```sh
52+
terraform init -upgrade
53+
```
54+
55+
4. Validate and plan:
56+
57+
```sh
58+
terraform validate
59+
terraform plan
60+
```
61+
62+
5. Apply:
63+
64+
```sh
65+
terraform apply -auto-approve
66+
```
67+
68+
## Outputs
69+
70+
| Output Name | Description |
71+
| --- | --- |
72+
| `video_indexer_account_id` | The resource ID of the Azure AI Video Indexer account. |
73+
| `video_indexer_principal_id` | The managed identity principal ID used for RBAC. |
74+
75+
<!-- START BADGE -->
76+
<div align="center">
77+
<img src="https://img.shields.io/badge/Total%20views-0-limegreen" alt="Total views">
78+
<p>Refresh Date: 2026-02-10</p>
79+
</div>
80+
<!-- END BADGE -->
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# main.tf
2+
3+
resource "azurerm_resource_group" "rg" {
4+
name = var.resource_group_name
5+
location = var.location
6+
tags = var.tags
7+
}
8+
9+
resource "azapi_resource" "storage_account" {
10+
type = "Microsoft.Storage/storageAccounts@2021-04-01"
11+
name = var.storage_account_name
12+
location = azurerm_resource_group.rg.location
13+
parent_id = azurerm_resource_group.rg.id
14+
15+
body = jsonencode({
16+
kind = "StorageV2"
17+
sku = {
18+
name = "Standard_LRS"
19+
}
20+
properties = {
21+
minimumTlsVersion = "TLS1_2"
22+
supportsHttpsTrafficOnly = true
23+
24+
# Many orgs enforce disabling key-based auth at the Storage Account level.
25+
# Using AzAPI avoids Terraform needing to poll the data plane with account keys.
26+
allowSharedKeyAccess = false
27+
28+
allowBlobPublicAccess = false
29+
}
30+
tags = var.tags
31+
})
32+
33+
response_export_values = [
34+
"id",
35+
"name"
36+
]
37+
}
38+
39+
resource "azapi_resource" "video_indexer" {
40+
type = "Microsoft.VideoIndexer/accounts@2024-01-01"
41+
name = var.video_indexer_account_name
42+
location = azurerm_resource_group.rg.location
43+
parent_id = azurerm_resource_group.rg.id
44+
45+
identity {
46+
type = "SystemAssigned"
47+
}
48+
49+
body = jsonencode({
50+
properties = {
51+
storageServices = {
52+
resourceId = azapi_resource.storage_account.id
53+
}
54+
}
55+
tags = var.tags
56+
})
57+
58+
response_export_values = [
59+
"id",
60+
"name",
61+
"identity.principalId"
62+
]
63+
}
64+
65+
resource "azurerm_role_assignment" "video_indexer_storage_blob_data_contributor" {
66+
scope = azapi_resource.storage_account.id
67+
role_definition_name = "Storage Blob Data Contributor"
68+
principal_id = jsondecode(azapi_resource.video_indexer.output).identity.principalId
69+
70+
depends_on = [
71+
azapi_resource.storage_account,
72+
azapi_resource.video_indexer
73+
]
74+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# outputs.tf
2+
3+
output "resource_group_id" {
4+
description = "The ID of the resource group."
5+
value = azurerm_resource_group.rg.id
6+
}
7+
8+
output "storage_account_id" {
9+
description = "The ID of the storage account linked to Video Indexer."
10+
value = azapi_resource.storage_account.id
11+
}
12+
13+
output "video_indexer_account_id" {
14+
description = "The resource ID of the Azure AI Video Indexer account."
15+
value = jsondecode(azapi_resource.video_indexer.output).id
16+
}
17+
18+
output "video_indexer_principal_id" {
19+
description = "The system-assigned managed identity principalId for the Video Indexer account."
20+
value = jsondecode(azapi_resource.video_indexer.output).identity.principalId
21+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# provider.tf
2+
# This file configures the Azure providers to interact with Azure resources.
3+
4+
terraform {
5+
required_version = ">= 1.8, < 2.0"
6+
7+
required_providers {
8+
azurerm = {
9+
source = "hashicorp/azurerm"
10+
version = "~> 3.116"
11+
}
12+
13+
azapi = {
14+
source = "Azure/azapi"
15+
version = "~> 1.13"
16+
}
17+
}
18+
}
19+
20+
provider "azurerm" {
21+
features {
22+
resource_group {
23+
prevent_deletion_if_contains_resources = false
24+
}
25+
}
26+
27+
# Uses the current Azure CLI context (az login + az account set)
28+
skip_provider_registration = false
29+
}
30+
31+
provider "azapi" {
32+
# Uses the current Azure CLI context (az login + az account set)
33+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
resource_group_name = "rg-media-services-dev"
2+
location = "East US"
3+
video_indexer_account_name = "vi-media-dev-001"
4+
storage_account_name = "stmediadev001abc" # must be globally unique
5+
6+
tags = {
7+
env = "dev"
8+
iac = "terraform"
9+
area = "media-services"
10+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# variables.tf
2+
3+
variable "resource_group_name" {
4+
description = "The name of the resource group to create."
5+
type = string
6+
}
7+
8+
variable "location" {
9+
description = "Azure region for deployment."
10+
type = string
11+
default = "East US"
12+
}
13+
14+
variable "video_indexer_account_name" {
15+
description = "The name of the Azure AI Video Indexer (ARM-based) account to create."
16+
type = string
17+
}
18+
19+
variable "storage_account_name" {
20+
description = "The name of the Storage Account to create and link to Video Indexer. Must be globally unique and meet Azure naming rules."
21+
type = string
22+
}
23+
24+
variable "tags" {
25+
description = "Tags applied to supported resources."
26+
type = map(string)
27+
default = {
28+
env = "dev"
29+
iac = "terraform"
30+
area = "media-services"
31+
}
32+
}

11_media-services/cdn/.terraform-provider-schema.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)