使用 Terraform 提供应用服务环境
Provision App Service Environment with Terraform
是否可以使用 Terraform 部署 Azure 应用服务环境?我似乎可以找到专门为此提供的提供商,所以不确定是否可以使用 azurerm_app_service 资源来完成。
"the team" 已经在这方面完成了工作。
https://github.com/terraform-providers/terraform-provider-azurerm/pull/869
但是,如果您阅读那里的帖子,您会发现 "Azure API (rather than the SDK)"(引用自文章)....(不是 terraform 团队的错)目前存在问题,所以这个"task" 目前处于不确定状态。
引自文章
"but we can't proceed with this until that's fixed, unfortunately."
使用 azurerm_template_deployment 作为 解决方法 似乎对我有用,它在 Terraform 中使用 ARM 模板。它确实需要很长时间的思考(在我的例子中是 47 分钟),但它似乎有效。我是这样使用的:
resource "azurerm_template_deployment" "test" {
name = "mytemplate001"
resource_group_name = "my-test-rg"
template_body = <<DEPLOY
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appServicePoolName": {
"type": "string",
"defaultValue": "[concat('sp', uniqueString(resourceGroup().id))]"
},
"appServiceEnvironmentName": {
"type": "string",
"defaultValue": "myenv-test"
}
},
"resources": [
{
"name": "[parameters('appServicePoolName')]",
"type": "Microsoft.Web/serverfarms",
"location": "West Europe",
"apiVersion": "2017-08-01",
"tags": {
"displayName": "My-Service-Pool"
},
"properties": {
"name": "[parameters('appServicePoolName')]",
"hostingEnvironment": "[parameters('appServiceEnvironmentName')]",
"hostingEnvironmentId": "[resourceId('Microsoft.Web/hostingEnvironments', parameters('appServiceEnvironmentName'))]"
},
"sku": {
"name": "I1",
"tier": "Isolated",
"size": "I1",
"family": "I"
}
}
]
}
DEPLOY
# these key-value pairs are passed into the ARM Template's `parameters` block
parameters {
"appServicePoolName" = "my-test-asp"
"appServiceEnvironmentName" = "myenv-test"
}
deployment_mode = "Incremental"
}
似乎有一个 problem with Azure Rest API 阻止了 Terraform 正确使用它。因此,希望它能尽快得到修复,我们将能够在 Terraform 中原生使用 App Service Environment。
是否可以使用 Terraform 部署 Azure 应用服务环境?我似乎可以找到专门为此提供的提供商,所以不确定是否可以使用 azurerm_app_service 资源来完成。
"the team" 已经在这方面完成了工作。
https://github.com/terraform-providers/terraform-provider-azurerm/pull/869
但是,如果您阅读那里的帖子,您会发现 "Azure API (rather than the SDK)"(引用自文章)....(不是 terraform 团队的错)目前存在问题,所以这个"task" 目前处于不确定状态。
引自文章
"but we can't proceed with this until that's fixed, unfortunately."
使用 azurerm_template_deployment 作为 解决方法 似乎对我有用,它在 Terraform 中使用 ARM 模板。它确实需要很长时间的思考(在我的例子中是 47 分钟),但它似乎有效。我是这样使用的:
resource "azurerm_template_deployment" "test" {
name = "mytemplate001"
resource_group_name = "my-test-rg"
template_body = <<DEPLOY
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appServicePoolName": {
"type": "string",
"defaultValue": "[concat('sp', uniqueString(resourceGroup().id))]"
},
"appServiceEnvironmentName": {
"type": "string",
"defaultValue": "myenv-test"
}
},
"resources": [
{
"name": "[parameters('appServicePoolName')]",
"type": "Microsoft.Web/serverfarms",
"location": "West Europe",
"apiVersion": "2017-08-01",
"tags": {
"displayName": "My-Service-Pool"
},
"properties": {
"name": "[parameters('appServicePoolName')]",
"hostingEnvironment": "[parameters('appServiceEnvironmentName')]",
"hostingEnvironmentId": "[resourceId('Microsoft.Web/hostingEnvironments', parameters('appServiceEnvironmentName'))]"
},
"sku": {
"name": "I1",
"tier": "Isolated",
"size": "I1",
"family": "I"
}
}
]
}
DEPLOY
# these key-value pairs are passed into the ARM Template's `parameters` block
parameters {
"appServicePoolName" = "my-test-asp"
"appServiceEnvironmentName" = "myenv-test"
}
deployment_mode = "Incremental"
}
似乎有一个 problem with Azure Rest API 阻止了 Terraform 正确使用它。因此,希望它能尽快得到修复,我们将能够在 Terraform 中原生使用 App Service Environment。