Azure-cli: Parameter 'resource_group_name' must conform to the following pattern: '^[-\\w\\._\\(\\)]+$'.

Created on 10 Nov 2016  路  8Comments  路  Source: Azure/azure-cli

I don't know why I'm getting this:

export RG=colemick-k8s-kube15-test000
az resource group create --name="${RG}" --location=westus2

Name                         Location
---------------------------  ----------
colemick-k8s-kube15-test000  westus2
az resource group deployment create \
   --name "${RG}-${RANDOM}" \
   --template-file './azuredeploy.json' \
   --parameters '@azuredeploy.parameters.json' \
   --resource-group="${RG}"

Parameter 'resource_group_name' must conform to the following pattern: '^[-\\w\\._\\(\\)]+$'.

I'm not a regex guru, but it seems like that should conform...

Most helpful comment

Just had this and was caused by using CRLF endings in my bash script file.

I changed them to LF and the problem was solved.

I figured it out by echoing a variable and seeing it had a \r on the end.

All 8 comments

az --version

azure-cli (0.1.0b8)

cloud (0.1.0b8)
component (0.1.0b8)
configure (0.1.0b8)
context (0.1.0b8)
core (0.1.0b8)
feedback (0.1.0b8)
network (0.1.0b8)
profile (0.1.0b8)
resource (0.1.0b8)
role (0.1.0b8)
storage (0.1.0b8)
vm (0.1.0b8)

Python (Linux) 3.5.2 (default, Nov  7 2016, 11:31:36)
[GCC 6.2.1 20160830]

When I put that regex and your RG-name into http://pythex.org/ it didn't match.

However, this did match: ^[-\w\\._\\(\\)]+$

Is this regex in your azuredeploy template?

How would that regex be in a template? That error is coming from CLI.

Is that RG name actually disallowed?

It looks like this is the problem in the REST API specs:

https://github.com/Azure/azure-rest-api-specs/blob/master/arm-resources/resources/2016-09-01/swagger/resources.json#L52

This is where your error is coming from. The CLI is simply wrapping the error in a CLIError to display it to you.

Nice, didn't know that was auto-gen'd too. I can file a bug against the specs repo unless you already are?

Although, maybe the regex is correct for .NET but you need to do translation in the autogeneration for Python to make it a python compatiable regex? I don't really know...

Opened an issue against the REST-API specs: https://github.com/Azure/azure-rest-api-specs/issues/711

Just had this and was caused by using CRLF endings in my bash script file.

I changed them to LF and the problem was solved.

I figured it out by echoing a variable and seeing it had a \r on the end.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

binderjoe picture binderjoe  路  3Comments

mmacy picture mmacy  路  3Comments

Kannaj picture Kannaj  路  3Comments

seanknox picture seanknox  路  3Comments

amarzavery picture amarzavery  路  3Comments