【问题标题】:msrest.exceptions.ValidationError: Parameter 'resource_group_name' must conform to the following pattern: '^[-\\w\\._\\(\\)]+$'msrest.exceptions.ValidationError:参数“resource_group_name”必须符合以下模式:“^[-\\w\\._\\(\\)]+$'
【发布时间】:2019-04-23 15:27:28
【问题描述】:

sathish@Azure:~/quickstart/python-docs-hello-world$ az webapp up -n appname 该命令因意外错误而失败。这是回溯:

Parameter 'resource_group_name' must conform to the following pattern: '^[-\\w\\._\\(\\)]+$'.
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 206, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 326, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 384, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 375, in _run_job
    cmd_copy.exception_handler(ex)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/commands.py", line 54, in _polish_bad_errors
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 354, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 145, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 451, in default_command_handler
    return op(**command_args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 2313, in webapp_up
    _create_new_rg = should_create_new_rg(cmd, default_rg, rg_name, is_linux)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/_create_util.py", line 282, in should_create_new_rg
    elif (_check_resource_group_exists(cmd, rg_name) and
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/_create_util.py", line 86, in _check_resource_group_exists
    return rcf.resource_groups.check_existence(rg_name)
  File "/opt/az/lib/python3.6/site-packages/azure/mgmt/resource/resources/v2018_05_01/operations/resource_groups_operations.py", line 61, in check_existence
    'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'),
  File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 592, in url
    data = self.validate(data, name, required=True, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 672, in validate
    raise ValidationError(key, name, value)
msrest.exceptions.ValidationError: Parameter 'resource_group_name' must conform to the following pattern: '^[-\\w\\._\\(\\)]+$'.

To open an issue, please run: 'az feedback'

【问题讨论】:

  • 您在 azure 请求中指定的任何资源组都不符合 azure 的预期。它甚至告诉您名称必须符合什么正则表达式。 ^[-\\w\\._\\(\\)]+$
  • 还有其他解决方案吗?因为资源组名称与默认正则表达式模式匹配。请为此提供任何其他解决方案。

标签: python exception azure-web-app-service azure-resource-group azure-cloud-shell


【解决方案1】:

我遇到了这个问题,但通过删除资源组名称周围的引号解决了这个问题。代表我犯了愚蠢的错误,但可能是这里的问题。

例如使用az group create -n my-groupname-rg -l northeurope 而不是:例如使用az group create -n 'my-groupname-rg' -l 'northeurope'

【讨论】:

    【解决方案2】:

    资源组名可以看Naming rules and restrictions

    【讨论】:

    • 您好,如果回答有帮助,请帮忙标记为回答。谢谢。
    • @SathishKannan,这里有一个类似的issue,你可以尝试在本地install the cli,然后使用本地azure cli 进行这个测试吗?
    猜你喜欢
    • 2020-07-25
    • 1970-01-01
    • 1970-01-01
    • 2018-04-24
    • 1970-01-01
    • 1970-01-01
    • 2018-05-20
    • 2018-09-14
    • 2021-11-22
    相关资源
    最近更新 更多