Azure

Deploy using Terraform

Currently supports only monolithic app with SQL Server as database (support for other databases are WIP). Terraform scripts will create Azure App Service, Azure SQL Server

Prerequisites

  1. Docker installed with docker compose and have push access to any of the docker repository like docker hub or Azure container registry.

  2. Azure CLI installed on your system. Terraform will require it to authenticate in Azure subscription.

  3. Terraform CLI installed on your system.

Steps to follow

  1. Execute generate app command and select app as Monolithic with Microsoft SQL server as database. Select yes to generate Terraform scripts. (default: is No) use-azure

  2. Use docker compose command to first build the docker image.

docker compose -f docker/app.yml build
  1. Tag the image built during the previous step to push to docker repository by using

docker tag <source-image> <destination-image>:version/tag
  1. Push the image to docker hub or any docker service provider by using

docker push <destination-image>:version/tag

Note: The docker image link and its tag will use as input to Terraform variables. 5. In the generated app folder, change directory to the Terraform folder.

cd terraform
  1. Login into your Azure CLI by using

az login

Note: Terraform plan command will work only if the user is authenticated using Azure CLI.

  1. Create a file (terraform.tfvars) in the Terraform folder to provide input to the Terraform main script using below content:

location                = "Central US"
subscription_id         = "<your-azure-subscription>"
mssql_admin_user        = "dbUser"
mssql_admin_password    = "yourStrong(!)Password"
docker_image            = "a5ingh/jhipster-dotnetcore-sampleapp"
docker_image_tag        = "0.1"
  1. Execute below terraform commands (one by one) to create resources (Azure app service, Azure SQL) and deploy as a docker image to app service:

    1. terraform init # to initialize terraform.

    2. terraform plan -out "MyAppPlan" # can choose any name instead of MyAppPlan.

    3. terraform apply "MyAppPlan" # it will create the resources and then provide you the link to your deployed app as output variable.

  2. You can use terraform destroy to delete/remove all the created resources once you are done using it.