Azure下运行terraspace up demo遇Net::HTTPNotFound错误,求原因
在Azure平台使用Terraspace搭建演示环境,已完成安装及环境变量配置(遵循官方文档步骤)。执行terraspace up demo命令时,资源组创建成功后触发如下错误,更换uksouth等不同区域后问题仍存在,请问可能的原因是什么?
错误日志:
Current directory: .terraspace-cache/eastus/dev/stacks/aks Creating Resource Group dev-eastus... Exception Armrest::Error: #Net::HTTPNotFound:0x00007f0e9b0f39c0 /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/armrest-0.1.3/lib/armrest/api/base.rb:43:in `request' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/armrest-0.1.3/lib/armrest/api/base.rb:18:in `block (2 levels) in class:Base' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/armrest-0.1.3/lib/armrest/services/storage_account.rb:12:in `check_name_availability' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace_plugin_azurerm-0.7.0/lib/terraspace_plugin_azurerm/interfaces/backend/storage_account.rb:17:in `exist?' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace_plugin_azurerm-0.7.0/lib/terraspace_plugin_azurerm/interfaces/backend/storage_account.rb:6:in `create' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace_plugin_azurerm-0.7.0/lib/terraspace_plugin_azurerm/interfaces/backend.rb:10:in `call' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/terraform/runner/backend.rb:25:in `create' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/terraform/runner.rb:51:in `block in terraform' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/hooks/builder.rb:25:in `run_hooks' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/hooks/concern.rb:6:in `run_hooks' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/terraform/runner.rb:50:in `terraform' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/terraform/runner.rb:15:in `block in run' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/terraform/runner.rb:97:in `time_took' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/terraform/runner.rb:14:in `run' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/cli/init.rb:23:in `block in init' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/3.1.0/timeout.rb:107:in `block in timeout' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/3.1.0/timeout.rb:36:in `block in catch' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/3.1.0/timeout.rb:36:in `catch' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/3.1.0/timeout.rb:36:in `catch' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/3.1.0/timeout.rb:123:in `timeout' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/cli/init.rb:22:in `init' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/cli/init.rb:12:in `run' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/cli/commander.rb:10:in `run' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/cli/up.rb:49:in `apply' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/cli/up.rb:26:in `perform' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/cli/up.rb:11:in `run' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/cli.rb:236:in `up' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/command.rb:76:in `dispatch' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/thor-1.2.2/lib/thor/base.rb:485:in `start' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/lib/terraspace/cli/concern.rb:65:in `start' /opt/hostedtoolcache/Ruby/3.1.4/x64/lib/ruby/gems/3.1.0/gems/terraspace-2.2.6/exe/terraspace:7:in `<top (required)>' /opt/hostedtoolcache/Ruby/3.1.4/x64/bin/terraspace:25:in `load' /opt/hostedtoolcache/Ruby/3.1.4/x64/bin/terraspace:25:in `'
从错误栈可以看出,问题出在调用Azure存储账户的check_name_availability接口时返回Net::HTTPNotFound,以下是常见原因:
权限不足:
虽然能创建资源组,但检查存储账户名称可用性需要Microsoft.Storage/checkNameAvailability/action权限。Azure部分场景下权限不足会返回404而非403,导致接口调用失败。可通过Azure门户或CLI检查当前身份的权限配置。存储账户名称不符合规则:
Azure存储账户名称要求3-24位,仅包含小写字母和数字。Terraspace自动生成的名称可能不符合规则,导致检查接口返回异常。可手动执行az storage account check-name --name <账户名>验证名称合法性。插件版本兼容性问题:
当前使用的armrest-0.1.3和terraspace_plugin_azurerm-0.7.0版本较旧,可能存在API端点调用错误或兼容性问题。尝试升级这两个依赖到最新版本后重试。Azure区域服务异常:
极少数情况下,目标区域的存储服务API端点可能临时故障,或订阅未启用该区域的存储服务(换多个区域后概率较低)。可通过Azure CLI手动创建存储账户,验证区域服务可用性。
内容的提问来源于stack exchange,提问作者Mesut Tekin

