Microsoft.ApiManagement 服務/快取 2023-09-01-preview

Bicep 資源定義

服務/快取資源類型可以使用目標作業來部署:

如需每個 API 版本中已變更屬性的清單,請參閱 變更記錄檔。

使用範例

Bicep 範例

部署 API 管理 Redis 快取的基本範例。

param resourceName string = 'acctest0001'
param location string = 'westeurope'

resource redis 'Microsoft.Cache/redis@2023-04-01' = {
  name: resourceName
  location: 'eastus'
  properties: {
    enableNonSslPort: true
    minimumTlsVersion: '1.2'
    sku: {
      capacity: 2
      family: 'C'
      name: 'Standard'
    }
  }
}

resource service 'Microsoft.ApiManagement/service@2021-08-01' = {
  name: resourceName
  location: location
  sku: {
    capacity: 0
    name: 'Consumption'
  }
  properties: {
    certificates: []
    customProperties: {
      'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30': 'false'
      'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10': 'false'
      'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11': 'false'
      'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10': 'false'
      'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11': 'false'
    }
    disableGateway: false
    publicNetworkAccess: 'Enabled'
    publisherEmail: 'pub1@email.com'
    publisherName: 'pub1'
    virtualNetworkType: 'None'
  }
}

resource cache 'Microsoft.ApiManagement/service/caches@2021-08-01' = {
  name: resourceName
  parent: service
  properties: {
    connectionString: '${redis.name}.redis.cache.windows.net:6380,password=${redis.listKeys().primaryKey},ssl=true,abortConnect=False'
    useFromLocation: 'default'
  }
}

Azure 已驗證的模組

下列 Azure 驗證模組 可用來部署此資源類型。

Module 描述
API 管理服務 - 快取 API 管理服務的 AVM 子模組 - 快取

Azure 快速入門範例

下列 Azure 快速入門範本 包含用於部署此資源類型的 Bicep 範例。

Bicep 檔案 描述
使用外部 Azure Cache for Redis 部署 API 管理 此範本示範如何使用外部 Azure Cache for Redis 實例作為 API 管理外部快取,在取用層中建立 Azure API 管理的實例。

資源格式

若要建立 Microsoft.ApiManagement/service/caches 資源,請將下列 Bicep 新增至範本。

resource symbolicname 'Microsoft.ApiManagement/service/caches@2023-09-01-preview' = {
  parent: resourceSymbolicName
  name: 'string'
  properties: {
    connectionString: 'string'
    description: 'string'
    resourceId: 'string'
    useFromLocation: 'string'
  }
}

屬性值

Microsoft.ApiManagement/service/caches

名字 描述 價值
名字 資源名稱 字串

約束:
最小長度 = 1
最大長度 = 80
模式 = ^[^*#&+:<>?]+$ (必要)
父代 在 Bicep 中,您可以指定子資源的父資源。 只有在父資源外部宣告子資源時,才需要新增這個屬性。

如需詳細資訊,請參閱 父資源外部的子資源。
類型的資源符號名稱:服務
性能 快取屬性詳細數據。 CacheContractProperties

CacheContractProperties

名字 描述 價值
Connection String (連接字串) 要快取的運行時間連接字串 字串

約束:
最大長度 = 300 (必要)
描述 快取描述 字串

約束:
最大長度 = 2000
資源ID 外部系統快取中實體的原始 URI 指向 字串

約束:
最大長度 = 2000
useFromLocation 使用快取的來源位置識別碼 (應該是 'default' 或有效的 Azure 區域識別碼) 字串

約束:
最大長度 = 256 (必要)

ARM 樣本資源定義

服務/快取資源類型可以使用目標作業來部署:

使用範例

Azure 快速入門範本

下列 Azure 快速入門範本 部署此資源類型。

範本 描述
使用外部 Azure Cache for Redis 部署 API 管理

部署至 Azure
此範本示範如何使用外部 Azure Cache for Redis 實例作為 API 管理外部快取,在取用層中建立 Azure API 管理的實例。

資源格式

若要建立 Microsoft.ApiManagement/service/caches 資源,請將下列 JSON 新增至範本。

{
  "type": "Microsoft.ApiManagement/service/caches",
  "apiVersion": "2023-09-01-preview",
  "name": "string",
  "properties": {
    "connectionString": "string",
    "description": "string",
    "resourceId": "string",
    "useFromLocation": "string"
  }
}

屬性值

Microsoft.ApiManagement/service/caches

名字 描述 價值
apiVersion API 版本 “2023-09-01-預覽”
名字 資源名稱 字串

約束:
最小長度 = 1
最大長度 = 80
模式 = ^[^*#&+:<>?]+$ (必要)
性能 快取屬性詳細數據。 CacheContractProperties
型別 資源類型 “Microsoft.ApiManagement/service/caches”

CacheContractProperties

名字 描述 價值
Connection String (連接字串) 要快取的運行時間連接字串 字串

約束:
最大長度 = 300 (必要)
描述 快取描述 字串

約束:
最大長度 = 2000
資源ID 外部系統快取中實體的原始 URI 指向 字串

約束:
最大長度 = 2000
useFromLocation 使用快取的來源位置識別碼 (應該是 'default' 或有效的 Azure 區域識別碼) 字串

約束:
最大長度 = 256 (必要)

Terraform (AzAPI 提供者) 資源定義

服務/快取資源類型可以使用目標作業來部署:

  • 資源團體 關於每個 API 版本變更屬性的清單,請參見 變更日誌。

使用範例

Terraform 範例

部署 API 管理 Redis 快取的基本範例。

terraform {
  required_providers {
    azapi = {
      source = "Azure/azapi"
    }
  }
}

provider "azapi" {
  skip_provider_registration = false
}

variable "resource_name" {
  type    = string
  default = "acctest0001"
}

variable "location" {
  type    = string
  default = "westeurope"
}

resource "azapi_resource" "resourceGroup" {
  type     = "Microsoft.Resources/resourceGroups@2020-06-01"
  name     = var.resource_name
  location = var.location
}

resource "azapi_resource" "service" {
  type      = "Microsoft.ApiManagement/service@2021-08-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      certificates = [
      ]
      customProperties = {
        "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30" = "false"
        "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10" = "false"
        "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11" = "false"
        "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10"         = "false"
        "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11"         = "false"
      }
      disableGateway      = false
      publicNetworkAccess = "Enabled"
      publisherEmail      = "pub1@email.com"
      publisherName       = "pub1"
      virtualNetworkType  = "None"
    }
    sku = {
      capacity = 0
      name     = "Consumption"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "redis" {
  type      = "Microsoft.Cache/redis@2023-04-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = "eastus"
  body = {
    properties = {
      sku = {
        capacity = 2
        family   = "C"
        name     = "Standard"
      }
      enableNonSslPort  = true
      minimumTlsVersion = "1.2"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

data "azapi_resource_action" "listKeys" {
  type                   = "Microsoft.Cache/redis@2023-04-01"
  resource_id            = azapi_resource.redis.id
  action                 = "listKeys"
  response_export_values = ["*"]
}

resource "azapi_resource" "cache" {
  type      = "Microsoft.ApiManagement/service/caches@2021-08-01"
  parent_id = azapi_resource.service.id
  name      = var.resource_name
  body = {
    properties = {
      connectionString = "${azapi_resource.redis.name}.redis.cache.windows.net:6380,password=${data.azapi_resource_action.listKeys.output.primaryKey},ssl=true,abortConnect=False"
      useFromLocation  = "default"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
  lifecycle {
    ignore_changes = [body.properties.connectionString]
  }
}

資源格式

若要建立 Microsoft.ApiManagement/service/caches 資源,請將下列 Terraform 新增至範本。

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.ApiManagement/service/caches@2023-09-01-preview"
  name = "string"
  parent_id = "string"
  body = {
    properties = {
      connectionString = "string"
      description = "string"
      resourceId = "string"
      useFromLocation = "string"
    }
  }
}

屬性值

Microsoft.ApiManagement/service/caches

名字 描述 價值
名字 資源名稱 字串

約束:
最小長度 = 1
最大長度 = 80
模式 = ^[^*#&+:<>?]+$ (必要)
父項識別碼 此資源為父系之資源的標識碼。 類型的資源標識碼:服務
性能 快取屬性詳細數據。 CacheContractProperties
型別 資源類型 “Microsoft.ApiManagement/service/caches@2023-09-01-preview”

CacheContractProperties

名字 描述 價值
Connection String (連接字串) 要快取的運行時間連接字串 字串

約束:
最大長度 = 300 (必要)
描述 快取描述 字串

約束:
最大長度 = 2000
資源ID 外部系統快取中實體的原始 URI 指向 字串

約束:
最大長度 = 2000
useFromLocation 使用快取的來源位置識別碼 (應該是 'default' 或有效的 Azure 區域識別碼) 字串

約束:
最大長度 = 256 (必要)