hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.51k stars 4.6k forks source link

Support for Azure App Service Slot Swap #12381

Open wviriya opened 3 years ago

wviriya commented 3 years ago

I was able to successfully deploy followed the document https://docs.microsoft.com/en-us/azure/developer/terraform/provision-infrastructure-using-azure-deployment-slots. However, any subsequence slot swap of the same slot will not work since Terraform configuration won't change from application deployment to the slot. This seems to be a one way push from any slot to production. The deployment slot designed to have bi-directional swap. The user should be able to swap the slots back i.e. dev to production or production to dev. Terraform module is https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service_active_slot. It would be great to have this capability.

Community Note

Description

New or Affected Resource(s)

Potential Terraform Configuration

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.

References

https://docs.microsoft.com/en-us/azure/developer/terraform/provision-infrastructure-using-azure-deployment-slots https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service_active_slot

benhamiltonpro commented 2 years ago

I just ran across this issue. As a workaround, I created an isolated swap folder with basically the bare minimum for the swap active slot action. Then on the terraform plan (or apply depending on your setup), I used the -replace option in order to get the swap to always happen. It forces the replacement of the swap resource, which is not an actual mapped entity to azure, only to terraform. So replacing it gets the desired effect.

Example: terraform plan -replace="azurerm_app_service_active_slot.mySlot" terraform apply

mapcrux commented 2 years ago

The swapping between slots seems to be a feature that still needs to be tackled. A full implementation of slot swapping I would imagine would have:

ritik-gupta commented 2 months ago

Hi, any update on this?