You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Terraform中部署V2版Azure Media Services而非默认V3版本

解决方案

首先明确:官方AzureRM Terraform Provider提供的azurerm_media_services_account原生资源是基于Media Services V3 API开发的,没有开放指定API版本的配置项,无法直接通过原生资源部署V2版本的Media Services实例。

可行实现方案

使用Terraform的ARM模板部署资源,直接调用你导出的V2版本API的部署模板来创建实例,具体操作如下:

  1. 替换你现有配置中azurerm_media_services_account资源块,改用azurerm_resource_group_template_deployment资源部署V2版本实例,示例配置如下:
resource "azurerm_resource_group_template_deployment" "media_services_v2" {
  name                = "media-v2-deployment"
  resource_group_name = azurerm_resource_group.rg.name
  deployment_mode     = "Incremental"

  template_content = <<TEMPLATE
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "mediaservices_name": {
            "type": "String"
        },
        "storage_account_id": {
            "type": "String"
        },
        "location": {
            "type": "String"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Media/mediaservices",
            "apiVersion": "2015-10-01",
            "name": "[parameters('mediaservices_name')]",
            "location": "[parameters('location')]",
            "properties": {
                "storageAccounts": [
                    {
                        "id": "[parameters('storage_account_id')]",
                        "isPrimary": true
                    }
                ]
            }
        }
    ]
}
TEMPLATE

  parameters_content = jsonencode({
    mediaservices_name = "${lower(var.customer)}${lower(var.env)}${lower(var.product)}-media"
    storage_account_id = azurerm_storage_account.stracc.id
    location = var.location
  })
}
  1. 后续如果需要关联V2版本Media Services的其他配置,无法直接使用azurerm_media_streaming_endpoint等原生V3资源,需要同样通过ARM模板或者调用Azure REST API的方式来配置。

注意事项

  • Media Services V2版本已经停止官方维护,微软官方推荐使用V3版本,建议优先评估业务是否可以适配V3版本的能力。
  • 如果你仍然需要使用V2版本,后续版本升级、问题修复都需要自行维护相关的ARM模板配置。

内容的提问来源于stack exchange,提问作者Igor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.29 02:18:02