IronSecureDoc 教程 部署到 Azure Deploy a Container Instance in Azure Curtis Chau 更新日期:6月 1, 2025 Download IronSecureDoc 免費下載 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English Use Terraform on Azure to deploy the IronSecureDoc Docker container and make it available with a public IP address and FQDN. Prerequisites Install and configure Terraform Authenticate Terraform to Azure 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 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 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 常見問題解答 如何使用 Terraform 在 Azure 中部署 Docker 容器? 要在 Azure 中使用 Terraform 部署 Docker 容器,你需要克隆 IronSecureDoc 的 GitHub 存儲庫模板,修改 `variables.tf` 中的資源名稱,並創建含有敏感數據的 `secret.tfvars` 文件。然後,通過 terraform init 初始化部署,並使用 terraform plan 和 terraform apply 創建和應用執行計畫。 設置 Terraform 用於 Azure 部署的必要步驟是什麼? 首先,安裝並配置 Terraform,然後將其驗證到 Azure。克隆 IronSecureDoc 專用的 GitHub 存儲庫,修改 `variables.tf` 文件中的資源名稱,並在 `secret.tfvars` 中管理敏感數據。最後,初始化 Terraform 並創建部署的執行計畫。 Azure 容器註冊表在此部署中的角色是什麼? Azure 容器註冊表用於存儲 Docker 映像。你需要將註冊表憑據附加到 `main.tf` 文件中,並在 `variables.tf` 和 `secret.tfvars` 中指定註冊表信息,以便部署能夠訪問和部署所需的 Docker 映像。 我如何驗證 Azure 中 Terraform 部署是否成功? 在應用 Terraform 執行計畫後,運行 terraform output 獲取公共 IP 地址或 FQDN。使用 Postman 或 curl 等工具發送 ping 請求給服務。成功的部署會返回 'pong'。 用於初始化 Azure 部署的 Terraform 的命令是什麼? 要初始化 Azure 部署的 Terraform,使用命令 terraform init -upgrade。這將下載管理 Azure 資源所需的提供程序插件。 如何在 Terraform 配置中處理敏感數據? 敏感數據如註冊表憑據和許可密鑰應存儲在 `secret.tfvars` 文件中。此文件在 Terraform 的計劃和應用過程中被引用,以安全地管理敏感信息。 使用 Terraform 在 Azure 中銷毀已部署資源的過程是什麼? 要使用 Terraform 銷毀 Azure 中的已部署資源,使用 terraform plan -destroy -var-file='secret.tfvars' -out main.tfplan 創建銷毀執行計畫,並使用 terraform apply main.tfplan 應用它。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 準備好開始了嗎? 版本: 2024.10 剛剛發布 免費下載 查看許可證