From b98920bd9b52f6c5ef454ef5b0e6638b1e73d3bf Mon Sep 17 00:00:00 2001 From: Julien Corioland Date: Fri, 31 May 2019 11:15:19 +0200 Subject: [PATCH 1/9] wip: windows containers in appsvc --- azurerm/helpers/azure/app_service.go | 20 ++++++++++++++++++++ azurerm/resource_arm_app_service_plan.go | 3 +++ 2 files changed, 23 insertions(+) diff --git a/azurerm/helpers/azure/app_service.go b/azurerm/helpers/azure/app_service.go index 0fc246ef015a..16e2727d58e1 100644 --- a/azurerm/helpers/azure/app_service.go +++ b/azurerm/helpers/azure/app_service.go @@ -398,12 +398,19 @@ func SchemaAppServiceSiteConfig() *schema.Schema { string(web.FtpsOnly), }, false), }, + "linux_fx_version": { Type: schema.TypeString, Optional: true, Computed: true, }, + "windows_fx_version": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "min_tls_version": { Type: schema.TypeString, Optional: true, @@ -564,6 +571,11 @@ func SchemaAppServiceDataSourceSiteConfig() *schema.Schema { Computed: true, }, + "windows_fx_version": { + Type: schema.TypeString, + Computed: true, + }, + "min_tls_version": { Type: schema.TypeString, Computed: true, @@ -1051,6 +1063,10 @@ func ExpandAppServiceSiteConfig(input interface{}) web.SiteConfig { siteConfig.LinuxFxVersion = utils.String(v.(string)) } + if v, ok := config["windows_fx_version"]; ok { + siteConfig.WindowsFxVersion = utils.String(v.(string)) + } + if v, ok := config["http2_enabled"]; ok { siteConfig.HTTP20Enabled = utils.Bool(v.(bool)) } @@ -1239,6 +1255,10 @@ func FlattenAppServiceSiteConfig(input *web.SiteConfig) []interface{} { result["linux_fx_version"] = *input.LinuxFxVersion } + if input.WindowsFxVersion != nil { + result["windows_fx_version"] = *input.WindowsFxVersion + } + if input.VnetName != nil { result["virtual_network_name"] = *input.VnetName } diff --git a/azurerm/resource_arm_app_service_plan.go b/azurerm/resource_arm_app_service_plan.go index 36105e599469..11ae037052b9 100644 --- a/azurerm/resource_arm_app_service_plan.go +++ b/azurerm/resource_arm_app_service_plan.go @@ -46,11 +46,14 @@ func resourceArmAppServicePlan() *schema.Resource { ValidateFunc: validation.StringInSlice([]string{ // @tombuildsstuff: I believe `app` is the older representation of `Windows` // thus we need to support it to be able to import resources without recreating them. + // @jcorioland: new SKU and kind 'xenon' have been added for Windows Containers support + // https://azure.microsoft.com/en-us/blog/announcing-the-public-preview-of-windows-container-support-in-azure-app-service/ "App", "elastic", "FunctionApp", "Linux", "Windows", + "xenon", }, true), DiffSuppressFunc: suppress.CaseDifference, }, From 476a2c49fe8e451d9199d6666230fd63821d1e63 Mon Sep 17 00:00:00 2001 From: Julien Corioland Date: Fri, 31 May 2019 11:18:05 +0200 Subject: [PATCH 2/9] fix panic because apimgmt was nil --- azurerm/config.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azurerm/config.go b/azurerm/config.go index 2885f6bb7681..caf9507a2d2b 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -501,10 +501,6 @@ func (c *ArmClient) registerAPIManagementClients(endpoint, subscriptionId string groupUsersClient := apimanagement.NewGroupUserClientWithBaseURI(endpoint, subscriptionId) c.configureClient(&groupUsersClient.Client, auth) - loggerClient := apimanagement.NewLoggerClientWithBaseURI(endpoint, subscriptionId) - c.configureClient(&loggerClient.Client, auth) - c.apimgmt.LoggerClient = loggerClient - policyClient := apimanagement.NewPolicyClientWithBaseURI(endpoint, subscriptionId) c.configureClient(&policyClient.Client, auth) @@ -565,6 +561,10 @@ func (c *ArmClient) registerAPIManagementClients(endpoint, subscriptionId string SubscriptionsClient: subscriptionsClient, UsersClient: usersClient, } + + loggerClient := apimanagement.NewLoggerClientWithBaseURI(endpoint, subscriptionId) + c.configureClient(&loggerClient.Client, auth) + c.apimgmt.LoggerClient = loggerClient } func (c *ArmClient) registerAppInsightsClients(endpoint, subscriptionId string, auth autorest.Authorizer) { From 9982a1aee094364f6c55d4d4df2fa98b9e00941d Mon Sep 17 00:00:00 2001 From: Julien Corioland Date: Fri, 31 May 2019 12:19:51 +0200 Subject: [PATCH 3/9] add support for xenon plan (PremiumContainer SKU) --- azurerm/resource_arm_app_service_plan.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/azurerm/resource_arm_app_service_plan.go b/azurerm/resource_arm_app_service_plan.go index 11ae037052b9..4e212717d47f 100644 --- a/azurerm/resource_arm_app_service_plan.go +++ b/azurerm/resource_arm_app_service_plan.go @@ -144,6 +144,11 @@ func resourceArmAppServicePlan() *schema.Resource { Computed: true, }, + "is_xenon": { + Type: schema.TypeBool, + Optional: true, + }, + "tags": tagsSchema(), }, } @@ -178,6 +183,13 @@ func resourceArmAppServicePlanCreateUpdate(d *schema.ResourceData, meta interfac sku := expandAzureRmAppServicePlanSku(d) properties := expandAppServicePlanProperties(d) + isXenon := d.Get("is_xenon").(bool) + properties.IsXenon = &isXenon + + if kind == "xenon" && !isXenon { + return fmt.Errorf("Creating or updating App Service Plan %q (Resource Group %q): when kind is set to xenon, is_xenon property should be set to true", name, resGroup) + } + appServicePlan := web.AppServicePlan{ Location: &location, Kind: &kind, From a24c85c4e56b5bdbc0f6fca0eb67b56b8d476f14 Mon Sep 17 00:00:00 2001 From: Julien Corioland Date: Fri, 31 May 2019 14:17:07 +0200 Subject: [PATCH 4/9] add xenon support to app_service_plan data source --- azurerm/data_source_app_service_plan.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/azurerm/data_source_app_service_plan.go b/azurerm/data_source_app_service_plan.go index 2e6a3846823f..9a218f0b3335 100644 --- a/azurerm/data_source_app_service_plan.go +++ b/azurerm/data_source_app_service_plan.go @@ -73,6 +73,11 @@ func dataSourceAppServicePlan() *schema.Resource { Computed: true, }, + "is_xenon": { + Type: schema.TypeBool, + Computed: true, + }, + "tags": tagsForDataSourceSchema(), }, } @@ -99,6 +104,7 @@ func dataSourceAppServicePlanRead(d *schema.ResourceData, meta interface{}) erro d.Set("name", name) d.Set("resource_group_name", resourceGroup) d.Set("kind", resp.Kind) + d.Set("is_xenon", resp.IsXenon) if location := resp.Location; location != nil { d.Set("location", azureRMNormalizeLocation(*location)) From 847c2e1cf89aba4fe823e3fbbda7cfde67291bfa Mon Sep 17 00:00:00 2001 From: Julien Corioland Date: Fri, 31 May 2019 15:02:50 +0200 Subject: [PATCH 5/9] support is_xenon property in app svc plan resource read --- azurerm/resource_arm_app_service_plan.go | 1 + 1 file changed, 1 insertion(+) diff --git a/azurerm/resource_arm_app_service_plan.go b/azurerm/resource_arm_app_service_plan.go index 4e212717d47f..131efefd7cd7 100644 --- a/azurerm/resource_arm_app_service_plan.go +++ b/azurerm/resource_arm_app_service_plan.go @@ -272,6 +272,7 @@ func resourceArmAppServicePlanRead(d *schema.ResourceData, meta interface{}) err d.Set("location", azureRMNormalizeLocation(*location)) } d.Set("kind", resp.Kind) + d.Set("is_xenon", resp.IsXenon) if props := resp.AppServicePlanProperties; props != nil { if err := d.Set("properties", flattenAppServiceProperties(props)); err != nil { From 1b0ee1f66d9c487eee59e7b003c3a15937e9a018 Mon Sep 17 00:00:00 2001 From: Julien Corioland Date: Fri, 31 May 2019 15:04:52 +0200 Subject: [PATCH 6/9] add tests for windows container support --- azurerm/data_source_app_service_plan_test.go | 50 ++++++++++++++ azurerm/data_source_app_service_test.go | 32 +++++++++ azurerm/resource_arm_app_service_plan_test.go | 50 ++++++++++++++ azurerm/resource_arm_app_service_test.go | 66 +++++++++++++++++++ 4 files changed, 198 insertions(+) diff --git a/azurerm/data_source_app_service_plan_test.go b/azurerm/data_source_app_service_plan_test.go index 150ba6e05823..0f5c0c8bdb8f 100644 --- a/azurerm/data_source_app_service_plan_test.go +++ b/azurerm/data_source_app_service_plan_test.go @@ -61,6 +61,29 @@ func TestAccDataSourceAzureRMAppServicePlan_complete(t *testing.T) { }) } +func TestAccDataSourceAzureRMAppServicePlan_basicWindowsContainer(t *testing.T) { + dataSourceName := "data.azurerm_app_service_plan.test" + rInt := tf.AccRandTimeInt() + location := testLocation() + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceAppServicePlan_basicWindowsContainer(rInt, location), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(dataSourceName, "kind", "xenon"), + resource.TestCheckResourceAttr(dataSourceName, "sku.#", "1"), + resource.TestCheckResourceAttr(dataSourceName, "sku.0.tier", "PremiumContainer"), + resource.TestCheckResourceAttr(dataSourceName, "sku.0.size", "PC2"), + resource.TestCheckResourceAttr(dataSourceName, "is_xenon", "true"), + ), + }, + }, + }) +} + func testAccDataSourceAppServicePlan_basic(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { @@ -119,3 +142,30 @@ data "azurerm_app_service_plan" "test" { } `, rInt, location, rInt) } + +func testAccDataSourceAppServicePlan_basicWindowsContainer(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + is_xenon = true + kind = "xenon" + + sku { + tier = "PremiumContainer" + size = "PC2" + } +} + +data "azurerm_app_service_plan" "test" { + name = "${azurerm_app_service_plan.test.name}" + resource_group_name = "${azurerm_app_service_plan.test.resource_group_name}" +} +`, rInt, location, rInt) +} diff --git a/azurerm/data_source_app_service_test.go b/azurerm/data_source_app_service_test.go index c0d9c875f9e5..e937096deaed 100644 --- a/azurerm/data_source_app_service_test.go +++ b/azurerm/data_source_app_service_test.go @@ -189,6 +189,26 @@ func TestAccDataSourceAzureRMAppService_minTls(t *testing.T) { }) } +func TestAccDataSourceAzureRMAppService_basicWindowsContainer(t *testing.T) { + dataSourceName := "data.azurerm_app_service.test" + rInt := tf.AccRandTimeInt() + location := testLocation() + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccDataSourceAppService_basicWindowsContainer(rInt, location), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(dataSourceName, "site_config.0.windows_fx_version", "DOCKER|mcr.microsoft.com/azure-app-service/samples/aspnethelloworld:latest"), + resource.TestCheckResourceAttr(dataSourceName, "app_settings.DOCKER_REGISTRY_SERVER_URL", "https://mcr.microsoft.com"), + ), + }, + }, + }) +} + func testAccDataSourceAppService_basic(rInt int, location string) string { config := testAccAzureRMAppService_basic(rInt, location) return fmt.Sprintf(` @@ -296,3 +316,15 @@ data "azurerm_app_service" "test" { } `, config) } + +func testAccDataSourceAppService_basicWindowsContainer(rInt int, location string) string { + config := testAccAzureRMAppService_basicWindowsContainer(rInt, location) + return fmt.Sprintf(` +%s + +data "azurerm_app_service" "test" { + name = "${azurerm_app_service.test.name}" + resource_group_name = "${azurerm_app_service.test.resource_group_name}" +} +`, config) +} diff --git a/azurerm/resource_arm_app_service_plan_test.go b/azurerm/resource_arm_app_service_plan_test.go index 098e595e67dd..5da6f3f23691 100644 --- a/azurerm/resource_arm_app_service_plan_test.go +++ b/azurerm/resource_arm_app_service_plan_test.go @@ -294,6 +294,34 @@ func TestAccAzureRMAppServicePlan_premiumConsumptionPlan(t *testing.T) { }) } +func TestAccAzureRMAppServicePlan_basicWindowsContainer(t *testing.T) { + resourceName := "azurerm_app_service_plan.test" + ri := tf.AccRandTimeInt() + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServicePlanDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMAppServicePlan_basicWindowsContainer(ri, testLocation()), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServicePlanExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "kind", "xenon"), + resource.TestCheckResourceAttr(resourceName, "is_xenon", "true"), + resource.TestCheckResourceAttr(resourceName, "sku.0.tier", "PremiumContainer"), + resource.TestCheckResourceAttr(resourceName, "sku.0.size", "PC2"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testCheckAzureRMAppServicePlanDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*ArmClient).appServicePlansClient @@ -595,3 +623,25 @@ resource "azurerm_app_service_plan" "test" { } `, rInt, location, rInt) } + +func testAccAzureRMAppServicePlan_basicWindowsContainer(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + kind = "xenon" + is_xenon = true + + sku { + tier = "PremiumContainer" + size = "PC2" + } +} +`, rInt, location, rInt) +} diff --git a/azurerm/resource_arm_app_service_test.go b/azurerm/resource_arm_app_service_test.go index fb171ecdff27..ff16427e4e42 100644 --- a/azurerm/resource_arm_app_service_test.go +++ b/azurerm/resource_arm_app_service_test.go @@ -1721,6 +1721,33 @@ func TestAccAzureRMAppService_multiAuthSettings(t *testing.T) { }) } +func TestAccAzureRMAppService_basicWindowsContainer(t *testing.T) { + resourceName := "azurerm_app_service.test" + ri := tf.AccRandTimeInt() + config := testAccAzureRMAppService_basicWindowsContainer(ri, testLocation()) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAppServiceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAppServiceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "site_config.0.windows_fx_version", "DOCKER|mcr.microsoft.com/azure-app-service/samples/aspnethelloworld:latest"), + resource.TestCheckResourceAttr(resourceName, "app_settings.DOCKER_REGISTRY_SERVER_URL", "https://mcr.microsoft.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testCheckAzureRMAppServiceDestroy(s *terraform.State) error { client := testAccProvider.Meta().(*ArmClient).appServicesClient @@ -3626,3 +3653,42 @@ resource "azurerm_app_service" "test" { } `, rInt, location, rInt, rInt, tenantID, web.AzureActiveDirectory) } + +func testAccAzureRMAppService_basicWindowsContainer(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_app_service_plan" "test" { + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + is_xenon = true + kind = "xenon" + + sku { + tier = "PremiumContainer" + size = "PC2" + } +} + +resource "azurerm_app_service" "test" { + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + app_service_plan_id = "${azurerm_app_service_plan.test.id}" + + site_config { + windows_fx_version = "DOCKER|mcr.microsoft.com/azure-app-service/samples/aspnethelloworld:latest" + } + + app_settings = { + "DOCKER_REGISTRY_SERVER_URL" = "https://mcr.microsoft.com", + "DOCKER_REGISTRY_SERVER_USERNAME" = "", + "DOCKER_REGISTRY_SERVER_PASSWORD" = "", + } +} +`, rInt, location, rInt, rInt) +} From ef864dedb7d91c13b0a362941517cfbff83d8591 Mon Sep 17 00:00:00 2001 From: Julien Corioland Date: Fri, 31 May 2019 15:11:04 +0200 Subject: [PATCH 7/9] fix indent in tests --- azurerm/data_source_app_service_plan_test.go | 22 ++++++------ azurerm/resource_arm_app_service_plan_test.go | 18 +++++----- azurerm/resource_arm_app_service_test.go | 34 +++++++++---------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/azurerm/data_source_app_service_plan_test.go b/azurerm/data_source_app_service_plan_test.go index 0f5c0c8bdb8f..bb24b23e73ee 100644 --- a/azurerm/data_source_app_service_plan_test.go +++ b/azurerm/data_source_app_service_plan_test.go @@ -146,26 +146,26 @@ data "azurerm_app_service_plan" "test" { func testAccDataSourceAppServicePlan_basicWindowsContainer(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%d" + location = "%s" } resource "azurerm_app_service_plan" "test" { - name = "acctestASP-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" is_xenon = true kind = "xenon" - sku { - tier = "PremiumContainer" - size = "PC2" - } + sku { + tier = "PremiumContainer" + size = "PC2" + } } data "azurerm_app_service_plan" "test" { - name = "${azurerm_app_service_plan.test.name}" - resource_group_name = "${azurerm_app_service_plan.test.resource_group_name}" + name = "${azurerm_app_service_plan.test.name}" + resource_group_name = "${azurerm_app_service_plan.test.resource_group_name}" } `, rInt, location, rInt) } diff --git a/azurerm/resource_arm_app_service_plan_test.go b/azurerm/resource_arm_app_service_plan_test.go index 5da6f3f23691..899c668de2f8 100644 --- a/azurerm/resource_arm_app_service_plan_test.go +++ b/azurerm/resource_arm_app_service_plan_test.go @@ -627,21 +627,21 @@ resource "azurerm_app_service_plan" "test" { func testAccAzureRMAppServicePlan_basicWindowsContainer(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%d" + location = "%s" } resource "azurerm_app_service_plan" "test" { - name = "acctestASP-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" kind = "xenon" is_xenon = true - sku { - tier = "PremiumContainer" - size = "PC2" - } + sku { + tier = "PremiumContainer" + size = "PC2" + } } `, rInt, location, rInt) } diff --git a/azurerm/resource_arm_app_service_test.go b/azurerm/resource_arm_app_service_test.go index ff16427e4e42..ffa1927281c4 100644 --- a/azurerm/resource_arm_app_service_test.go +++ b/azurerm/resource_arm_app_service_test.go @@ -3657,38 +3657,38 @@ resource "azurerm_app_service" "test" { func testAccAzureRMAppService_basicWindowsContainer(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%d" + location = "%s" } resource "azurerm_app_service_plan" "test" { - name = "acctestASP-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" + name = "acctestASP-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" is_xenon = true kind = "xenon" - sku { - tier = "PremiumContainer" - size = "PC2" - } + sku { + tier = "PremiumContainer" + size = "PC2" + } } resource "azurerm_app_service" "test" { - name = "acctestAS-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" + name = "acctestAS-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" app_service_plan_id = "${azurerm_app_service_plan.test.id}" site_config { - windows_fx_version = "DOCKER|mcr.microsoft.com/azure-app-service/samples/aspnethelloworld:latest" + windows_fx_version = "DOCKER|mcr.microsoft.com/azure-app-service/samples/aspnethelloworld:latest" } app_settings = { - "DOCKER_REGISTRY_SERVER_URL" = "https://mcr.microsoft.com", - "DOCKER_REGISTRY_SERVER_USERNAME" = "", - "DOCKER_REGISTRY_SERVER_PASSWORD" = "", - } + "DOCKER_REGISTRY_SERVER_URL" = "https://mcr.microsoft.com", + "DOCKER_REGISTRY_SERVER_USERNAME" = "", + "DOCKER_REGISTRY_SERVER_PASSWORD" = "", + } } `, rInt, location, rInt, rInt) } From 86ea415045167493e90d8571556f55bc32804f2b Mon Sep 17 00:00:00 2001 From: Julien Corioland Date: Fri, 31 May 2019 15:23:13 +0200 Subject: [PATCH 8/9] update docs for app svc windows containers --- website/docs/d/app_service.html.markdown | 2 ++ website/docs/d/app_service_plan.html.markdown | 2 ++ website/docs/r/app_service.html.markdown | 2 ++ website/docs/r/app_service_plan.html.markdown | 22 +++++++++++++++++++ 4 files changed, 28 insertions(+) diff --git a/website/docs/d/app_service.html.markdown b/website/docs/d/app_service.html.markdown index d310167f14fe..0f79842d6421 100644 --- a/website/docs/d/app_service.html.markdown +++ b/website/docs/d/app_service.html.markdown @@ -111,6 +111,8 @@ A `ip_restriction` block exports the following: * `linux_fx_version` - Linux App Framework and version for the AppService. +* `windows_fx_version` - Windows Container Docker Image for the AppService. + * `local_mysql_enabled` - Is "MySQL In App" Enabled? This runs a local MySQL instance with your app and shares resources from the App Service plan. * `managed_pipeline_mode` - The Managed Pipeline Mode used in this App Service. diff --git a/website/docs/d/app_service_plan.html.markdown b/website/docs/d/app_service_plan.html.markdown index 120987c21afb..7009bb501c36 100644 --- a/website/docs/d/app_service_plan.html.markdown +++ b/website/docs/d/app_service_plan.html.markdown @@ -44,6 +44,8 @@ output "app_service_plan_id" { * `maximum_number_of_workers` - The maximum number of workers supported with the App Service Plan's sku. +* `is_xenon` - A flag that indicates if it's a xenon plan (support for Windows Container) + --- A `sku` block supports the following: diff --git a/website/docs/r/app_service.html.markdown b/website/docs/r/app_service.html.markdown index be27dd4b6ba3..c86f45850c1d 100644 --- a/website/docs/r/app_service.html.markdown +++ b/website/docs/r/app_service.html.markdown @@ -139,6 +139,8 @@ A `site_config` block supports the following: * `linux_fx_version` - (Optional) Linux App Framework and version for the App Service. Possible options are a Docker container (`DOCKER|`), a base-64 encoded Docker Compose file (`COMPOSE|${filebase64("compose.yml")}`) or a base-64 encoded Kubernetes Manifest (`KUBE|${filebase64("kubernetes.yml")}`). +* `windows_fx_version` - (Optional) The Windows Docker container image (`DOCKER|`) + Additional examples of how to run Containers via the `azurerm_app_service` resource can be found in [the `./examples/app-service` directory within the Github Repository](https://github.com/terraform-providers/terraform-provider-azurerm/tree/master/examples/app-service). * `managed_pipeline_mode` - (Optional) The Managed Pipeline Mode. Possible values are `Integrated` and `Classic`. Defaults to `Integrated`. diff --git a/website/docs/r/app_service_plan.html.markdown b/website/docs/r/app_service_plan.html.markdown index 26a043a7a234..4bbd197cf455 100644 --- a/website/docs/r/app_service_plan.html.markdown +++ b/website/docs/r/app_service_plan.html.markdown @@ -73,6 +73,28 @@ resource "azurerm_app_service_plan" "test" { } ``` +## Example Usage (Windows Container) + +```hcl +resource "azurerm_resource_group" "test" { + name = "api-rg-pro" + location = "West Europe" +} + +resource "azurerm_app_service_plan" "test" { + name = "api-appserviceplan-pro" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + kind = "xenon" + is_xenon = true + + sku { + tier = "PremiumContainer" + size = "PC2" + } +} +``` + ## Argument Reference The following arguments are supported: From 4a590c87baea445bc6ac0d3646194f2a68d2a590 Mon Sep 17 00:00:00 2001 From: Julien Corioland Date: Fri, 31 May 2019 15:33:44 +0200 Subject: [PATCH 9/9] example for app service with windows containers --- .../app-service/windows-container/README.md | 3 ++ .../app-service/windows-container/main.tf | 34 +++++++++++++++++++ .../app-service/windows-container/outputs.tf | 3 ++ .../windows-container/variables.tf | 7 ++++ 4 files changed, 47 insertions(+) create mode 100644 examples/app-service/windows-container/README.md create mode 100644 examples/app-service/windows-container/main.tf create mode 100644 examples/app-service/windows-container/outputs.tf create mode 100644 examples/app-service/windows-container/variables.tf diff --git a/examples/app-service/windows-container/README.md b/examples/app-service/windows-container/README.md new file mode 100644 index 000000000000..4dfff8646c0e --- /dev/null +++ b/examples/app-service/windows-container/README.md @@ -0,0 +1,3 @@ +## Example: App Service configured for Windows Container + +This example provisions an App Service inside an App Service Plan which is configured to run a Windows Container. \ No newline at end of file diff --git a/examples/app-service/windows-container/main.tf b/examples/app-service/windows-container/main.tf new file mode 100644 index 000000000000..315f98c6b797 --- /dev/null +++ b/examples/app-service/windows-container/main.tf @@ -0,0 +1,34 @@ +resource "azurerm_resource_group" "example" { + name = "${var.prefix}-resources" + location = "${var.location}" +} + +resource "azurerm_app_service_plan" "example" { + name = "${var.prefix}-asp" + location = "${azurerm_resource_group.example.location}" + resource_group_name = "${azurerm_resource_group.example.name}" + kind = "xenon" + is_xenon = true + + sku { + tier = "PremiumContainer" + size = "PC2" + } +} + +resource "azurerm_app_service" "example" { + name = "${var.prefix}-appservice" + location = "${azurerm_resource_group.example.location}" + resource_group_name = "${azurerm_resource_group.example.name}" + app_service_plan_id = "${azurerm_app_service_plan.example.id}" + + site_config { + windows_fx_version = "DOCKER|mcr.microsoft.com/azure-app-service/samples/aspnethelloworld:latest" + } + + app_settings = { + "DOCKER_REGISTRY_SERVER_URL" = "https://mcr.microsoft.com", + "DOCKER_REGISTRY_SERVER_USERNAME" = "", + "DOCKER_REGISTRY_SERVER_PASSWORD" = "", + } +} diff --git a/examples/app-service/windows-container/outputs.tf b/examples/app-service/windows-container/outputs.tf new file mode 100644 index 000000000000..f9936277c60b --- /dev/null +++ b/examples/app-service/windows-container/outputs.tf @@ -0,0 +1,3 @@ +output "website_url" { + value = "${azurerm_app_service.example.default_site_hostname}" +} diff --git a/examples/app-service/windows-container/variables.tf b/examples/app-service/windows-container/variables.tf new file mode 100644 index 000000000000..fcd1745ba3e7 --- /dev/null +++ b/examples/app-service/windows-container/variables.tf @@ -0,0 +1,7 @@ +variable "prefix" { + description = "The prefix used for all resources in this example" +} + +variable "location" { + description = "The Azure location where all resources in this example should be created" +}