Azure / Azure/azure-cli

Az policy assignment slash is parsed as %2F

Open
#17,635 1 comment 0 reactions 1 assignee Claimed by @zhoxing-ms View on GitHub
feature-request Policy
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

When I try to create a policy assingment trough the CLI from a docker container (caf rover) the command fails. In the debug I see the slashes (/) are parsed as %2F. When I run the exact same command from MacOS the policy assignment creation is succesful.

Using the same login account and same Azure CLI version.

MacOs:

```
@MacBook ~ % az version
{
"azure-cli": "2.17.1",
"azure-cli-core": "2.17.1",
"azure-cli-telemetry": "1.0.6",
"extensions": {
"virtual-wan": "0.2.4"
}
}

az policy assignment create --policy /providers/Microsoft.Management/managementgroups/MyMgtGroup/providers/Microsoft.Authorization/policyDefinitions/ES-Deny-GatewaySubnet --scope /subscriptions/ --debug

urllib3.connectionpool : Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool : https://management.azure.com:443 "GET /providers/Microsoft.Management/managementgroups/MyMgtGroup/providers/Microsoft.Authorization/policyDefinitions/ES-Deny-GatewaySubnet?api-version=2019-09-01 HTTP/1.1" 200 None
msrest.http_logger : Response status: 200
```

Docker container (MS CAF Rover (CentOS))

```
[vscode@hostname caf]$ az version
{
"azure-cli": "2.17.1",
"azure-cli-core": "2.17.1",
"azure-cli-telemetry": "1.0.6",
"extensions": {}
}

az policy assignment create --policy /providers/Microsoft.Management/managementgroups/MyMgtGroup/providers/Microsoft.Authorization/policyDefinitions/ES-Deny-GatewaySubnet --scope /subscriptions/ --debug

urllib3.connectionpool : Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool : https://management.azure.com:443 "GET /subscriptions/2fdb8075-ab62-4837-a4c2-a706a8b6f9b8/providers/Microsoft.Authorization/policyDefinitions/%2Fproviders%2FMicrosoft.Management%2Fmanagementgroups%2FMyMgtGroup%2Fproviders%2FMicrosoft.Authorization%2FpolicyDefinitions%2FES-Deny-GatewaySubnet?api-version=2016-12-01 HTTP/1.1" 404 115
msrest.http_logger : Response status: 404
```

### **This is autogenerated. Please review and update as needed.**

## Describe the bug

**Command Name**
`az policy assignment create`

**Errors:**
```
ResourceNotFoundError: The request uri is invalid. The requested resource is not found.
```

## To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

- _Put any pre-requisite steps here..._
- `az policy assignment create --policy {} --scope {} --debug`

## Expected Behavior

## Environment Summary
```
Linux-4.19.121-linuxkit-x86_64-with-centos-7.9.2009-Core
Python 3.6.8
Installer: RPM

azure-cli 2.17.1 *

```
## Additional Context

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.