» azurerm_app_service_slot
Manages an App Service Slot (within an App Service).
Note: When using Slots - the app_settings
, connection_string
and site_config
blocks on the azurerm_app_service
resource will be overwritten when promoting a Slot using the azurerm_app_service_active_slot
resource.
» Example Usage (.net 4.x)
resource "random_id" "server" {
keepers = {
azi_id = 1
}
byte_length = 8
}
resource "azurerm_resource_group" "test" {
name = "some-resource-group"
location = "West Europe"
}
resource "azurerm_app_service_plan" "test" {
name = "some-app-service-plan"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
tier = "Standard"
size = "S1"
}
}
resource "azurerm_app_service" "test" {
name = "${random_id.server.hex}"
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 {
dotnet_framework_version = "v4.0"
}
app_settings = {
"SOME_KEY" = "some-value"
}
connection_string {
name = "Database"
type = "SQLServer"
value = "Server=some-server.mydomain.com;Integrated Security=SSPI"
}
}
resource "azurerm_app_service_slot" "test" {
name = "${random_id.server.hex}"
app_service_name = "${azurerm_app_service.test.name}"
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 {
dotnet_framework_version = "v4.0"
}
app_settings = {
"SOME_KEY" = "some-value"
}
connection_string {
name = "Database"
type = "SQLServer"
value = "Server=some-server.mydomain.com;Integrated Security=SSPI"
}
}
» Example Usage (Java 1.8)
resource "random_id" "server" {
keepers = {
azi_id = 1
}
byte_length = 8
}
resource "azurerm_resource_group" "test" {
name = "some-resource-group"
location = "West Europe"
}
resource "azurerm_app_service_plan" "test" {
name = "some-app-service-plan"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
tier = "Standard"
size = "S1"
}
}
resource "azurerm_app_service" "test" {
name = "${random_id.server.hex}"
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 {
java_version = "1.8"
java_container = "JETTY"
java_container_version = "9.3"
}
}
resource "azurerm_app_service_slot" "test" {
name = "${random_id.server.hex}"
app_service_name = "${azurerm_app_service.test.name}"
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 {
java_version = "1.8"
java_container = "JETTY"
java_container_version = "9.3"
}
}
» Argument Reference
The following arguments are supported:
-
name
- (Required) Specifies the name of the App Service Slot component. Changing this forces a new resource to be created. -
resource_group_name
- (Required) The name of the resource group in which to create the App Service Slot component. -
location
- (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. -
app_service_plan_id
- (Required) The ID of the App Service Plan within which to create this App Service Slot. Changing this forces a new resource to be created. -
app_service_name
- (Required) The name of the App Service within which to create the App Service Slot. Changing this forces a new resource to be created. -
app_settings
- (Optional) A key-value pair of App Settings. -
connection_string
- (Optional) Anconnection_string
block as defined below. -
client_affinity_enabled
- (Optional) Should the App Service Slot send session affinity cookies, which route client requests in the same session to the same instance? -
enabled
- (Optional) Is the App Service Slot Enabled? -
https_only
- (Optional) Can the App Service Slot only be accessed via HTTPS? Defaults tofalse
. -
site_config
- (Optional) Asite_config
object as defined below. -
identity
- (Optional) A Managed Service Identity block as defined below. -
tags
- (Optional) A mapping of tags to assign to the resource.
connection_string
supports the following:
-
name
- (Required) The name of the Connection String. -
type
- (Required) The type of the Connection String. Possible values areAPIHub
,Custom
,DocDb
,EventHub
,MySQL
,NotificationHub
,PostgreSQL
,RedisCache
,ServiceBus
,SQLAzure
andSQLServer
. -
value
- (Required) The value for the Connection String.
site_config
supports the following:
-
app_command_line
- (Optional) App command line to launch, e.g./sbin/myserver -b 0.0.0.0
. -
always_on
- (Optional) Should the app be loaded at all times? Defaults tofalse
. -
cors
- (Optional) Acors
block as defined below. -
default_documents
- (Optional) The ordering of default documents to load, if an address isn't specified. -
dotnet_framework_version
- (Optional) The version of the .net framework's CLR used in this App Service Slot. Possible values arev2.0
(which will use the latest version of the .net framework for the .net CLR v2 - currently.net 3.5
) andv4.0
(which corresponds to the latest version of the .net CLR v4 - which at the time of writing is.net 4.7.1
). For more information on which .net CLR version to use based on the .net framework you're targeting - please see this table. Defaults tov4.0
. -
http2_enabled
- (Optional) Is HTTP2 Enabled on this App Service? Defaults tofalse
. -
ip_restriction
- (Optional) A List of objects representing ip restrictions as defined below. -
java_container
- (Optional) The Java Container to use. If specifiedjava_version
andjava_container_version
must also be specified. Possible values areJETTY
andTOMCAT
. -
java_container_version
- (Optional) The version of the Java Container to use. If specifiedjava_version
andjava_container
must also be specified. -
java_version
- (Optional) The version of Java to use. If specifiedjava_container
andjava_container_version
must also be specified. Possible values are1.7
,1.8
and11
. -
local_mysql_enabled
- (Optional) Is "MySQL In App" Enabled? This runs a local MySQL instance with your app and shares resources from the App Service plan.
NOTE: MySQL In App is not intended for production environments and will not scale beyond a single instance. Instead you may wish to use Azure Database for MySQL.
-
managed_pipeline_mode
- (Optional) The Managed Pipeline Mode. Possible values areIntegrated
andClassic
. Defaults toIntegrated
. -
min_tls_version
- (Optional) The minimum supported TLS version for the app service. Possible values are1.0
,1.1
, and1.2
. Defaults to1.2
for new app services. -
php_version
- (Optional) The version of PHP to use in this App Service Slot. Possible values are5.5
,5.6
,7.0
,7.1
and7.2
. -
python_version
- (Optional) The version of Python to use in this App Service Slot. Possible values are2.7
and3.4
. -
remote_debugging_enabled
- (Optional) Is Remote Debugging Enabled? Defaults tofalse
. -
remote_debugging_version
- (Optional) Which version of Visual Studio should the Remote Debugger be compatible with? Possible values areVS2012
,VS2013
,VS2015
andVS2017
. -
scm_type
- (Optional) The type of Source Control enabled for this App Service Slot. Defaults toNone
. Possible values are:BitbucketGit
,BitbucketHg
,CodePlexGit
,CodePlexHg
,Dropbox
,ExternalGit
,ExternalHg
,GitHub
,LocalGit
,None
,OneDrive
,Tfs
,VSO
andVSTSRM
-
use_32_bit_worker_process
- (Optional) Should the App Service Slot run in 32 bit mode, rather than 64 bit mode?
Note: Deployment Slots are not supported in the Free
, Shared
, or Basic
App Service Plans.
-
virtual_network_name
- (Optional) The name of the Virtual Network which this App Service Slot should be attached to. -
websockets_enabled
- (Optional) Should WebSockets be enabled?
A cors
block supports the following:
-
allowed_origins
- (Optional) A list of origins which should be able to make cross-origin calls.*
can be used to allow all calls. -
support_credentials
- (Optional) Are credentials supported?
A identity
block supports the following:
-
type
- (Required) Specifies the identity type of the App Service. At this time the only allowed value isSystemAssigned
.
The assigned principal_id
and tenant_id
can be retrieved after the App Service Slot has been created.
Elements of ip_restriction
block support:
-
ip_address
- (Required) The IP Address used for this IP Restriction. -
subnet_mask
- (Optional) The Subnet mask used for this IP Restriction. Defaults to255.255.255.255
.
» Attributes Reference
The following attributes are exported:
-
id
- The ID of the App Service Slot. -
default_site_hostname
- The Default Hostname associated with the App Service Slot - such asmysite.azurewebsites.net
» Import
App Service Slots can be imported using the resource id
, e.g.
terraform import azurerm_app_service_slot.instance1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/sites/website1/slots/instance1