Azure / Azure/bicep

Unable to force restore registry modules

Open
#12,752 7 comments 0 reactions 0 assignees View on GitHub
Quality Sprint
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Bicep version**
\> az bicep version
Bicep CLI version 0.23.1 (b02de2da48)

\> az --version
azure-cli 2.55.0

core 2.55.0
telemetry 1.1.0

Dependencies:
msal 1.24.0b2
azure-mgmt-resource 23.1.0b2

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\work\.azure\cliextensions'

Python (Windows) 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:21:31) [MSC v.1936 32 bit (Intel)]

**Describe the bug**
When running `az bicep restore -f .\main.bicep --force` following error is displayed:
> Error BCP190: The module with reference "br:\.azurecr.io/bicepmodules/messagingservice:default" has not been restored.

When running `az bicep restore -f .\main.bicep` the modules are restored as expected.

I am successfully logged in with `az login`. Deleting cache at `%USERPROFILE%\.bicep\br\` does not seem to make a difference.

**To Reproduce**
Steps to reproduce the behavior:
1. Run `az bicep restore -f .\main.bicep --force` with main.bicep containing a reference to azure registry.

**Additional context**
```
> az bicep restore -f .\main.bicep --force --debug
cli.knack.cli: Command arguments: ['bicep', 'restore', '-f', '.\\main.bicep', '--force', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'bicep': ['azure.cli.command_modules.resource']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: resource 0.111 51 228
cli.azure.cli.core: Total (1) 0.111 51 228
cli.azure.cli.core: Loaded 51 groups, 228 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : bicep restore
cli.azure.cli.core: Command table: bicep restore
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\work\.azure\commands\2023-12-14.10-30-16.bicep_restore.39464.log'.
az_command_data_logger: command args: bicep restore -f {} --force --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x03D25028>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x03D2E398>, .add_cache_arguments at 0x03D2E3E8>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x03D2E348>]
cli.azure.cli.command_modules.resource._bicep: Current value of "use_binary_from_path": false.
cli.azure.cli.command_modules.resource._bicep: Bicep CLI installation path: C:\Users\work\.azure\bin\bicep.exe
cli.azure.cli.command_modules.resource._bicep: Bicep CLI installed: True.
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 312, in _run_command
File "subprocess.py", line 502, in check_returncode
subprocess.CalledProcessError: Command '['C:\\Users\\work\\.azure\\bin\\bicep.exe', 'restore', '.\\main.bicep', '--force']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 663, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 697, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 333, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 4559, in restore_bicep_file
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 107, in run_bicep_command
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 328, in _run_command
azure.cli.core.azclierror.UnclassifiedUserFault: (25,32) : Error BCP190: The module with reference "br:.azurecr.io/bicepmodules/messagingservice:default" has not been restored.

cli.azure.cli.core.azclierror: (25,32) : Error BCP190: The module with reference "br:.azurecr.io/bicepmodules/messagingservice:default" has not been restored.
az_command_data_logger: (25,32) : Error BCP190: The module with reference "br:.azurecr.io/bicepmodules/messagingservice:default" has not been restored.
cli.knack.cli: Event: Cli.PostExecute []
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 6.466 seconds (init: 0.266, invoke: 6.200)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3629 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry\__init__.pyc C:\Users\work\.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing `az bicep restore -f .\main.bicep --force` with a registry module, then read the Azure CLI entry points shown in the traceback: `custom.py` at `restore_bicep_file` and `_bicep.py` at `run_bicep_command`. Done means forced restore succeeds for the registry module without BCP190, while normal restore behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.