azure-cli: az bicep build broken in CLI 2.22.0

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Describe the bug Running az bicep build gives a python error:

The command failed with an unexpected error. Here is the traceback:
type object 'datetime.datetime' has no attribute 'fromisoformat'
Traceback (most recent call last):
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 231, in invoke
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 657, in execute
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 691, in _run_job
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 328, in __call__
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/__init__.py", line 807, in default_command_handler
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 3294, in build_bicep_file   
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 63, in run_bicep_command    
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 152, in _load_bicep_version_check_result_from_cache
AttributeError: type object 'datetime.datetime' has no attribute 'fromisoformat'

To Reproduce

  • Upgrade to Azure CLI 2.22.0
  • Run az bicep build -f somefile.bicep

Expected behavior

Bicep build should work

Environment summary Installed using az upgrade and repaired using the MSI. Both don’t work. Windows 10, x64. az bicep build command ran from a git bash terminal.

Additional context

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 16 (8 by maintainers)

Most upvoted comments

That’s great @zhoxing-ms

I just updated to the latest version and everything works again. Thanks for the quick response 👍

@IJsbrandVV Hi, we released a new version (2.22.1) of hotfix to address this issue today. Please upgrade CLI to the latest version (2.22.1) and try again.

@zhoxing-ms already submitted a PR: https://github.com/Azure/azure-cli/pull/17675. Can you take a look?

I get the same when trying to run a deployment via az deployment...

➜  mgmt_group: az deployment tenant create -l uksouth -f main.bicep
type object 'datetime.datetime' has no attribute 'fromisoformat'

➜  mgmt_group: python3

Python 3.8.5 (default, Jan 27 2021, 15:41:15)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> from datetime import datetime
>>> datetime.fromisoformat('2021-04-13')
datetime.datetime(2021, 4, 13, 0, 0)

>>> datetime.
datetime.astimezone(        datetime.isoweekday(        datetime.timestamp(
datetime.combine(           datetime.max                datetime.timetuple(
datetime.ctime(             datetime.microsecond        datetime.timetz(
datetime.date(              datetime.min                datetime.today(
datetime.day                datetime.minute             datetime.toordinal(
datetime.dst(               datetime.month              datetime.tzinfo
datetime.fold               datetime.mro(               datetime.tzname(
datetime.fromisocalendar(   datetime.now(               datetime.utcfromtimestamp(
datetime.fromisoformat(     datetime.replace(           datetime.utcnow(
datetime.fromordinal(       datetime.resolution         datetime.utcoffset(
datetime.fromtimestamp(     datetime.second             datetime.utctimetuple(
datetime.hour               datetime.strftime(          datetime.weekday(
datetime.isocalendar(       datetime.strptime(          datetime.year
datetime.isoformat(         datetime.time(

>>> datetime._

I am running the deployment from a fresh build of my Docker container built this morning: https://github.com/fluffy-cakes/devops_tools/