Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for number_of_workers in app_service #10143

Merged
merged 6 commits into from
Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions azurerm/internal/services/web/app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,13 @@ func schemaAppServiceSiteConfig() *schema.Schema {
Optional: true,
},

"number_of_workers": {
AdamCoulterOz marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(1, 100),
Computed: true,
},

"linux_fx_version": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -774,6 +781,11 @@ func schemaAppServiceDataSourceSiteConfig() *schema.Schema {
Computed: true,
},

"number_of_workers": {
Type: schema.TypeInt,
Computed: true,
},

"linux_fx_version": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -1637,6 +1649,10 @@ func expandAppServiceSiteConfig(input interface{}) (*web.SiteConfig, error) {
siteConfig.HealthCheckPath = utils.String(v.(string))
}

if v, ok := config["number_of_workers"]; ok && v.(int) != 0 {
siteConfig.NumberOfWorkers = utils.Int32(int32(v.(int)))
}

if v, ok := config["min_tls_version"]; ok {
siteConfig.MinTLSVersion = web.SupportedTLSVersions(v.(string))
}
Expand Down Expand Up @@ -1750,6 +1766,10 @@ func flattenAppServiceSiteConfig(input *web.SiteConfig) []interface{} {
result["health_check_path"] = *input.HealthCheckPath
}

if input.NumberOfWorkers != nil {
result["number_of_workers"] = *input.NumberOfWorkers
}

result["min_tls_version"] = string(input.MinTLSVersion)

result["cors"] = FlattenWebCorsSettings(input.Cors)
Expand Down
52 changes: 52 additions & 0 deletions azurerm/internal/services/web/app_service_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,22 @@ func TestAccAppService_healthCheckPath(t *testing.T) {
})
}

func TestAccAppService_numberOfWorkers(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_app_service", "test")
r := AppServiceResource{}

data.ResourceTest(t, r, []resource.TestStep{
{
Config: r.numberOfWorkers(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("site_config.0.number_of_workers").HasValue("1"),
),
},
data.ImportStep(),
})
}

// Note: to specify `linux_fx_version` the App Service Plan must be of `kind = "Linux"`, and `reserved = true`
func TestAccAppService_linuxFxVersion(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_app_service", "test")
Expand Down Expand Up @@ -4074,6 +4090,42 @@ resource "azurerm_app_service" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func (r AppServiceResource) numberOfWorkers(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

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
per_site_scaling = true

sku {
tier = "Standard"
size = "S1"
}
}

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 {
number_of_workers = 1
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func (r AppServiceResource) linuxFxVersion(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/app_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ A `site_config` block exports the following:

* `health_check_path` - The health check path to be pinged by App Service.

* `number_of_workers` - The scaled number of workers (for per site scaling) of this App Service.

* `ip_restriction` - One or more `ip_restriction` blocks as defined above.

* `scm_use_main_ip_restriction` - IP security restrictions for scm to use main.
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/app_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ A `site_config` block supports the following:

* `ftps_state` - (Optional) State of FTP / FTPS service for this App Service. Possible values include: `AllAllowed`, `FtpsOnly` and `Disabled`.

* `health_check_path` - (Optional) The health check path to be pinged by App Service. [For more information - please see the corresponding Kudu Wiki page](https://github.com/projectkudu/kudu/wiki/Health-Check-(Preview)).
* `health_check_path` - (Optional) The health check path to be pinged by App Service. [For more information - please see App Service health check announcement](https://azure.github.io/AppService/2020/08/24/healthcheck-on-app-service.html).

~> **Note:** This functionality is in Preview and is subject to changes (including breaking changes) on Azure's end
* `number_of_workers` - (Optional) The scaled number of workers (for per site scaling) of this App Service. Requires that `per_site_scaling` is enabled on the `azurerm_app_service_plan`. [For more information - please see Microsoft documentation on high-density hosting](https://docs.microsoft.com/en-us/azure/app-service/manage-scale-per-app).

* `http2_enabled` - (Optional) Is HTTP2 Enabled on this App Service? Defaults to `false`.

Expand Down