繁体   English   中英

如何使用 Terraform 创建 Python 运行时为 3.6 的 Azure Web 应用程序

[英]How do you create a Azure Web app with a python runtime of 3.6 using Terraform

当您在为 kind=Linux 创建 Azure 应用服务时尝试使用 python_version =3.6 时,Terraform 0.13 会返回错误。 看起来这在 Terraform 中不是有效选项,但在 Azure 中是有效选项。 我需要查看其他选项吗? 在此配置中,Azure 不支持 python_Version 3.4。

例子:

resource "azurerm_resource_group" "ref-webapp-group" {                   
  name     = "${var.ref-prefix}-webapp-rg"                               
  location = "eastus2"                                                   
                                                                         
  tags = var.common-tags                                                 
}                                                                        
                                                                         
resource "azurerm_app_service_plan" "appserviceplan" {                   
  name                = "SOMEPREFIX-appserviceplan"                         
  location            = azurerm_resource_group.ref-webapp-group.location 
  resource_group_name = azurerm_resource_group.ref-webapp-group.name     
  kind = "Linux"                                                         
  reserved = true                                                        
                                                                         
  sku {                                                                  
    tier = "Standard"                                                    
    size = "S1"                                                          
  }                                                                      
}                                                                        
                                                                         
resource "azurerm_app_service" "webapp" {                                
  name                = "SOMEPREFIX-webapp"                                 
  location            = azurerm_resource_group.ref-webapp-group.location 
  resource_group_name = azurerm_resource_group.ref-webapp-group.name     
  app_service_plan_id = azurerm_app_service_plan.appserviceplan.id       
                                                                         
  site_config {                                                          
    python_version = 3.6                                                 
  }                                                                      
                                                                         
  app_settings = {                                                       
    "SOME_KEY" = "some-value"                                            
  }                                                                      
}            

好的,通过一些调查,您似乎可以使用 linux_fx_version 参数来部署不同的运行时间。 您可以使用以下命令:

az webapp list-runtimes --linux

列出运行时,然后您可以将其放入 terraform 脚本中,如下所示:

 resource "azurerm_resource_group" "ref-webapp-group" {                     
   name     = "${var.ref-prefix}-webapp-rg"                                 
   location = "eastus2"                                                     
                                                                            
   tags = var.common-tags                                                   
 }                                                                          
                                                                            
 resource "azurerm_app_service_plan" "appserviceplan" {                     
   name                = "SOMEPREFIX-appserviceplan"                           
   location            = azurerm_resource_group.ref-webapp-group.location   
   resource_group_name = azurerm_resource_group.ref-webapp-group.name       
   kind = "Linux"                                                           
   reserved = true                                                          
                                                                            
   sku {                                                                    
     tier = "Standard"                                                      
     size = "S1"                                                            
   }                                                                        
 }                                                                          
                                                                            
 resource "azurerm_app_service" "webapp" {                                  
   name                = "SOMEPREFIX-webapp"                                   
   location            = azurerm_resource_group.ref-webapp-group.location   
   resource_group_name = azurerm_resource_group.ref-webapp-group.name       
   app_service_plan_id = azurerm_app_service_plan.appserviceplan.id         
                                                                            
   site_config {                                                            
     linux_fx_version = "PYTHON|3.6"                                        
   }                                                                        
                                                                            
   app_settings = {                                                         
     "SOME_KEY" = "some-value"                                              
   }                                                                        
 }                                                                          

这在我在 Terraform 文档中可以找到的任何地方都没有记录,并且我在那里的文档中的任何地方都找不到 Microsoft 的记录。 我确实在 Microsoft 文档的 git hub 错误上找到了它: https : //github.com/MicrosoftDocs/azure-docs/issues/47749

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM