IronSecureDoc 教程 部署到 Azure Deploy a Container Instance in Azure Curtis Chau 已更新:六月 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 容器? 要使用 Terraform 在 Azure 上部署 Docker 容器,您需要克隆 IronSecureDoc 的 GitHub 存储库模板,修改 `variables.tf` 中的资源名称,并创建一个包含敏感数据的 `secret.tfvars` 文件。然后,使用 terraform init 初始化部署,并使用 terraform plan 和 terraform apply 创建和应用执行计划。 在 Azure 部署中设置 Terraform 的必要步骤是什么? 首先,安装并配置 Terraform,然后对 Azure 进行身份验证。克隆 IronSecureDoc 的特定 GitHub 存储库,在 `variables.tf` 文件中修改资源名称,并在 `secret.tfvars` 中管理敏感数据。最后,初始化 Terraform 并为部署创建执行计划。 Azure 容器注册在此部署中的作用是什么? Azure 容器注册用于存储 Docker 映像。您需要在 `main.tf` 文件中添加注册凭证,并在 `variables.tf` 和 `secret.tfvars` 中指定注册信息,以便部署访问和部署必要的 Docker 映像。 如何验证我的 Terraform 部署在 Azure 中是否成功? 应用 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 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。 准备开始了吗? 版本: 2024.10 刚刚发布 免费下载 查看许可证