Deploy a Container Instance in Azure

Use Terraform on Azure to deploy the IronSecureDoc Docker container and make it available with a public IP address and FQDN.

Prerequisites

Step 1: Clone GitHub Repository Template

We have the GitHub Repository template ready for you to clone and get started immediately here:

https://github.com/iron-software/IronSecureDoc-Terraform/

Step 2: Modify All Resource Names

Modify All Resource Names in variables.tf

  • resource_group_name: Name of the resource group.
  • resource_group_location: Location of the resource group. You can find the region from REGIONS.md and use the second column to fill in this variable.
  • container_group_name: Name of the container group.
  • container_name: Name of the container.
  • image_tag: The tag of the image to deploy; it can be latest or any specific version number.
  • Other variables do not need to be changed.

Create secret.tfvars to Contain All Sensitive Data

Populate the following variables in secret.tfvars.

Azure Container Registry

Append to main.tf after dns_name_label = var.dns_name_label:

image_registry_credential {
  server   = var.registry_server
  username = var.registry_username
  password = var.registry_password
}

Add to variables.tf:

variable "registry_server" {
  type        = string
  sensitive   = false
  description = "The server for the container registry. Required if the image is stored in a private registry."
}

variable "registry_username" {
  type        = string
  sensitive   = true
  description = "Username for the container registry. Required if the image is stored in a private registry."
}

variable "registry_password" {
  type        = string
  sensitive   = true
  description = "Password for the container registry. Required if the image is stored in a private registry."
}

Add to secret.tfvars:

registry_server   = "<registry-name>.azurecr.io"
registry_username = "YOUR-REGISTRY-USERNAME"
registry_password = "YOUR-REGISTRY-PASSWORD"
license_key       = "YOUR-LICENSE-KEY"

Docker Hub

Add to secret.tfvars:

license_key = "YOUR-LICENSE-KEY"

Step 3: Initialize Terraform

Run terraform init to initialize the Terraform deployment. This command downloads the Azure provider required to manage your Azure resources.

terraform init -upgrade
terraform init -upgrade
SHELL

Step 4: Create a Terraform Execution Plan

Run terraform plan to create an execution plan.

terraform plan -var-file="secret.tfvars" -out main.tfplan
terraform plan -var-file="secret.tfvars" -out main.tfplan
SHELL

Step 5: Apply a Terraform Execution Plan

Run terraform apply to apply the execution plan to your cloud infrastructure.

terraform apply main.tfplan
terraform apply main.tfplan
SHELL

Step 6: Verify the Results

  1. When you apply the execution plan, Terraform outputs the public IP address. To display the IP address again, run terraform output.

    terraform output -raw container_ipv4_address
    terraform output -raw container_ipv4_address
    SHELL

    Or display the FQDN.

    terraform output -raw container_fqdn
    terraform output -raw container_fqdn
    SHELL
  2. Use Postman or curl to validate. The expected result should return pong.

    curl http://<container_ipv4_address>:8080/v1/document-services/ping
    curl http://<container_ipv4_address>:8080/v1/document-services/ping
    SHELL

    Or use the FQDN.

    curl http://<container_fqdn>:8080/v1/document-services/ping
    curl http://<container_fqdn>:8080/v1/document-services/ping
    SHELL

Step 7: Destroy the Resource

  • Create an execution plan for destroying the resource.

    terraform plan -destroy -var-file="secret.tfvars" -out main.tfplan
    terraform plan -destroy -var-file="secret.tfvars" -out main.tfplan
    SHELL
  • Apply an execution destroy plan.

    terraform apply main.tfplan
    terraform apply main.tfplan
    SHELL

Frequently Asked Questions

What is the purpose of deploying a Docker container in Azure?

Deploying the IronSecureDoc Docker container in Azure allows you to secure documents using IronSecureDoc with a public IP address and FQDN.

What are the prerequisites for setting up a document security solution in Azure?

Before setting up IronSecureDoc in Azure, you need to install and configure Terraform and authenticate it to Azure.

How do I clone the GitHub repository template for the deployment?

You can clone the GitHub repository template for IronSecureDoc from the following URL: https://github.com/iron-software/IronSecureDoc-Terraform/.

What variables need to be modified in the Terraform configuration for my Azure setup?

In the `variables.tf` file, you need to modify the `resource_group_name`, `resource_group_location`, `container_group_name`, `container_name`, and `image_tag`. Sensitive data should be included in the `secret.tfvars` file.

How do I initialize the deployment process?

To initialize the Terraform deployment, run the command `terraform init -upgrade`, which downloads the necessary Azure provider for managing your resources.

What command is used to create an execution plan for deployment?

You can create a Terraform execution plan by running the command `terraform plan -var-file='secret.tfvars' -out main.tfplan`.

How do I verify the deployment results for a document service?

To verify the deployment, you can run `terraform output` to get the public IP address or FQDN and use Postman or curl to validate the setup by sending a ping request.

What steps are involved in destroying the deployed resources in Azure?

To destroy the resources, create a destroy execution plan using `terraform plan -destroy -var-file='secret.tfvars' -out main.tfplan` and apply it with `terraform apply main.tfplan`.

Chaknith Bin
Software Engineer
Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.