> ## Content Index
> Fetch the complete content index at: https://codeisahighway.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Workaround for error 'utf-8' codec can't decode byte 0x82 using Azure CLI deployment and Bicep
- URL: https://codeisahighway.com/workaround-for-error-utf-8-codec-cant-decode-byte-0x82-using-azure-cli-deployment-and-bicep/
- Published: 2021-05-11T10:34:00.000Z
- Updated: 2026-07-31T19:44:16.000Z
- Author: Stephane Lapointe
- Tags: Microsoft Azure, Azure CLI, Bicep, Bug, HowTo, Infrastructure As Code, Azure Resource Manager, #Import 2023-07-11 16:44, #Import 2026-09-04 10:31, #Import 2026-09-04 13:56

We migrated most of our automation from ARM Templates to Bicep in the recent months and things have been good so far. We ran into an issue deploying a bicep file containing French characters using Azure CLI. The message was: `'utf-8' codec can't decode byte 0x82 in position 1197: invalid start byte`

## The problem

I usually write things in English when I code so this was a non-issue for us until... We wanted to write non-compliant messages in French in our Azure Policy. Here is an example that contains the French character **é** and reproduce my error:

```bicep
targetScope = 'managementGroup'

var policyAssignmentName = substring(replace(guid('testassignment-#01'), '-', ''), 0, 23)

resource policyAssignment 'Microsoft.Authorization/policyAssignments@2020-09-01' = {
  name: policyAssignmentName
  properties: {
    policyDefinitionId: '/providers/Microsoft.Authorization/policyDefinitions/0473574d-2d43-4217-aefe-941fcdf7e684'
    displayName: 'AzCLI and Bicep encoding bug'
    description: 'AzCLI and Bicep encoding bug'
    enforcementMode: 'Default'
    parameters: {
      listOfAllowedLocations: {
        value: [
          'canadaeast'
          'canadacentral'
        ]
      }
    }
    nonComplianceMessages:[
      {
        message: 'La région qui a été choisi n\'est pas valide...'
      }
    ]
  }
}

```

As you can see, I get the error mentioned at the top when invoking the following command:

```powershell
az deployment mg create --management-group-id experimental --location canadaeast -f .\azcli-bicep-bug.bicep

'utf-8' codec can't decode byte 0x82 in position 1179: invalid start byte
```

The error is that the character **é** is badly handled. UTF-8 is used instead of Unicode in the Bicep wrapper \_bicep.py.

An issue has been filled on the GitHub repo of Azure CLI [#18029](https://github.com/Azure/azure-cli/issues/18029?ref=codeisahighway.com)

## The workaround

So... this is not working as a one-time operation, calling `az deployment`. Bicep can convert to and from ARM Templates. What I ended up doing until this issue is fixed is:

Generate an ARM template from my bicep file and deploy that ARM template. Two steps instead of one.

```powershell
az bicep build -f .\azcli-bicep-bug.bicep

az deployment mg create --management-group-id experimental --location canadaeast -f .\azcli-bicep-bug.json
```

Hope it can help some of you!

## References

- [Microsoft Azure CLI](https://github.com/Azure/azure-cli?ref=codeisahighway.com)
- [Azure deployment using Bicep and French characters: 'utf-8' codec can't decode byte 0x82](https://github.com/Azure/azure-cli/issues/18029?ref=codeisahighway.com)
- [Bicep](https://github.com/Azure/bicep?ref=codeisahighway.com)
- [Bicep Playground](https://bicepdemo.z22.web.core.windows.net/?ref=codeisahighway.com)