Skip to content

Conversation

@polatengin
Copy link
Member

@polatengin polatengin commented Jun 29, 2023

Related command

Following list of commands are added;

  • az bicep build-params

  • az bicep generate-params

  • az bicep decompile-params

Description

"bicep cli" got new command additions recently;

  • az bicep build-params: builds the given .bicepparam file and creates '.parameters.json` file

  • az bicep generate-params: generates a .bicepparam or .parameters.json file, based on the --output-param {bicepparam, file} argument, from the given .bicep file

  • az bicep decompile-params: generates a .bicepparam file from the given .parameters.json file

History Notes
[ARM] az bicep build-params: Support generating parameters.json file from the given bicepparam file with the --file argument
[ARM] az bicep decompile-params: Support generating parameters.bicepparam file from the given parameters.json file with the --file argument
[ARM] az bicep generate-params: Support generating main.parameters.json with the parameters that doesn't have default values in the given .bicep file
[ARM] az bicep generate-params: Add new parameter --output-format to support generating parameter file in bicepparam and json formats
[ARM] az bicep generate-params: Add new parameter --include-params to support generating parameter file with all the parameters in the given bicep file, or with only parameters that doesn't have default values in the given bicep file


This checklist is used to make sure that common guidelines for a pull request are followed.


azdev style resource command output;

image

azdev linter resource command output;

image

@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Jun 29, 2023

️✔️AzureCLI-FullTest
️✔️acr
️✔️2020-09-01-hybrid
️✔️3.10
️✔️3.9
️✔️latest
️✔️3.10
️✔️3.9
️✔️acs
️✔️2020-09-01-hybrid
️✔️3.10
️✔️3.9
️✔️latest
️✔️3.10
️✔️3.9
️✔️advisor
️✔️latest
️✔️3.10
️✔️3.9
️✔️ams
️✔️latest
️✔️3.10
️✔️3.9
️✔️apim
️✔️latest
️✔️3.10
️✔️3.9
️✔️appconfig
️✔️latest
️✔️3.10
️✔️3.9
️✔️appservice
️✔️latest
️✔️3.10
️✔️3.9
️✔️aro
️✔️latest
️✔️3.10
️✔️3.9
️✔️backup
️✔️latest
️✔️3.10
️✔️3.9
️✔️batch
️✔️latest
️✔️3.10
️✔️3.9
️✔️batchai
️✔️latest
️✔️3.10
️✔️3.9
️✔️billing
️✔️latest
️✔️3.10
️✔️3.9
️✔️botservice
️✔️latest
️✔️3.10
️✔️3.9
️✔️cdn
️✔️latest
️✔️3.10
️✔️3.9
️✔️cloud
️✔️latest
️✔️3.10
️✔️3.9
️✔️cognitiveservices
️✔️latest
️✔️3.10
️✔️3.9
️✔️config
️✔️latest
️✔️3.10
️✔️3.9
️✔️configure
️✔️latest
️✔️3.10
️✔️3.9
️✔️consumption
️✔️latest
️✔️3.10
️✔️3.9
️✔️container
️✔️latest
️✔️3.10
️✔️3.9
️✔️core
️✔️2018-03-01-hybrid
️✔️3.10
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.10
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.10
️✔️3.9
️✔️latest
️✔️3.10
️✔️3.9
️✔️cosmosdb
️✔️latest
️✔️3.10
️✔️3.9
️✔️databoxedge
️✔️2019-03-01-hybrid
️✔️3.10
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.10
️✔️3.9
️✔️latest
️✔️3.10
️✔️3.9
️✔️dla
️✔️latest
️✔️3.10
️✔️3.9
️✔️dls
️✔️latest
️✔️3.10
️✔️3.9
️✔️dms
️✔️latest
️✔️3.10
️✔️3.9
️✔️eventgrid
️✔️latest
️✔️3.10
️✔️3.9
️✔️eventhubs
️✔️latest
️✔️3.10
️✔️3.9
️✔️feedback
️✔️latest
️✔️3.10
️✔️3.9
️✔️find
️✔️latest
️✔️3.10
️✔️3.9
️✔️hdinsight
️✔️latest
️✔️3.10
️✔️3.9
️✔️identity
️✔️latest
️✔️3.10
️✔️3.9
️✔️iot
️✔️2019-03-01-hybrid
️✔️3.10
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.10
️✔️3.9
️✔️latest
️✔️3.10
️✔️3.9
️✔️keyvault
️✔️2018-03-01-hybrid
️✔️3.10
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.10
️✔️3.9
️✔️latest
️✔️3.10
️✔️3.9
️✔️kusto
️✔️latest
️✔️3.10
️✔️3.9
️✔️lab
️✔️latest
️✔️3.10
️✔️3.9
️✔️managedservices
️✔️latest
️✔️3.10
️✔️3.9
️✔️maps
️✔️latest
️✔️3.10
️✔️3.9
️✔️marketplaceordering
️✔️latest
️✔️3.10
️✔️3.9
️✔️monitor
️✔️latest
️✔️3.10
️✔️3.9
️✔️mysql
️✔️latest
️✔️3.10
️✔️3.9
️✔️netappfiles
️✔️latest
️✔️3.10
️✔️3.9
️✔️network
️✔️2018-03-01-hybrid
️✔️3.10
️✔️3.9
️✔️latest
️✔️3.10
️✔️3.9
️✔️policyinsights
️✔️latest
️✔️3.10
️✔️3.9
️✔️privatedns
️✔️latest
️✔️3.10
️✔️3.9
️✔️profile
️✔️latest
️✔️3.10
️✔️3.9
️✔️rdbms
️✔️latest
️✔️3.10
️✔️3.9
️✔️redis
️✔️latest
️✔️3.10
️✔️3.9
️✔️relay
️✔️latest
️✔️3.10
️✔️3.9
️✔️resource
️✔️2018-03-01-hybrid
️✔️3.10
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.10
️✔️3.9
️✔️latest
️✔️3.10
️✔️3.9
️✔️role
️✔️latest
️✔️3.10
️✔️3.9
️✔️search
️✔️latest
️✔️3.10
️✔️3.9
️✔️security
️✔️latest
️✔️3.10
️✔️3.9
️✔️servicebus
️✔️latest
️✔️3.10
️✔️3.9
️✔️serviceconnector
️✔️latest
️✔️3.10
️✔️3.9
️✔️servicefabric
️✔️latest
️✔️3.10
️✔️3.9
️✔️signalr
️✔️latest
️✔️3.10
️✔️3.9
️✔️sql
️✔️latest
️✔️3.10
️✔️3.9
️✔️sqlvm
️✔️latest
️✔️3.10
️✔️3.9
️✔️storage
️✔️2018-03-01-hybrid
️✔️3.10
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.10
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.10
️✔️3.9
️✔️latest
️✔️3.10
️✔️3.9
️✔️synapse
️✔️latest
️✔️3.10
️✔️3.9
️✔️telemetry
️✔️2018-03-01-hybrid
️✔️3.10
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.10
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.10
️✔️3.9
️✔️latest
️✔️3.10
️✔️3.9
️✔️util
️✔️latest
️✔️3.10
️✔️3.9
️✔️vm
️✔️2018-03-01-hybrid
️✔️3.10
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.10
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.10
️✔️3.9
️✔️latest
️✔️3.10
️✔️3.9

@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Jun 29, 2023

⚠️AzureCLI-BreakingChangeTest
⚠️resource
rule cmd_name rule_message suggest_message
⚠️ 1001 - CmdAdd bicep build-params cmd bicep build-params added
⚠️ 1001 - CmdAdd bicep decompile-params cmd bicep decompile-params added
⚠️ 1006 - ParaAdd bicep generate-params cmd bicep generate-params added parameter include_params
⚠️ 1006 - ParaAdd bicep generate-params cmd bicep generate-params added parameter output_format

@ghost ghost added the Auto-Assign Auto assign by bot label Jun 29, 2023
@ghost ghost requested a review from zhoxing-ms June 29, 2023 05:30
@yonzhan
Copy link
Collaborator

yonzhan commented Jun 29, 2023

BICEP

@ghost ghost requested a review from yonzhan June 29, 2023 05:30
@ghost ghost assigned zhoxing-ms Jun 29, 2023
@ghost ghost added the ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group label Jun 29, 2023
@polatengin polatengin changed the title [BICEP] reflecting bicep cli updates to az bicep command [BICEP] reflecting bicep cli updates to az bicep command Jun 29, 2023
@polatengin polatengin marked this pull request as ready for review July 6, 2023 02:20
@anthony-c-martin
Copy link
Member

@zhoxing-ms please could we have a review on this?

Copy link
Contributor

@shenglol shenglol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me, but you may need to fix the style and linter issues.

@polatengin
Copy link
Member Author

Changes look good to me, but you may need to fix the style and linter issues.

thanks for the approval @shenglol, I just updated the PR with linter/style fixes 👍

@zhoxing-ms zhoxing-ms changed the title [BICEP] reflecting bicep cli updates to az bicep command [ARM] az bicep: reflecting bicep cli updates to az bicep command Jul 25, 2023
@zhoxing-ms
Copy link
Contributor

@polatengin Please resolve these CLI linter issues~

@zhoxing-ms
Copy link
Contributor

Please refer to the guideline to write the description of those PR changes in the History Notes section of PR description. Please note that this content will be synced to the release notes of CLI. Such as #26261
image

@zhoxing-ms
Copy link
Contributor

Please note that we are launching the release for this sprint this week. Please resolve all comments by tomorrow, otherwise the release of this PR will have to be postponed to the next sprint (on 09-05)

@shenglol
Copy link
Contributor

@polatengin The CI failed because there is no tests for the new commands:
image

Can you add some tests in https://github.com/Azure/azure-cli/blob/dev/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_custom.py?

@zhoxing-ms
Copy link
Contributor

To reflect recent changes on the "bicep cli" to az bicep command

You need to add some more specific descriptions for these new commands and parameters so that customers can understand these new features

@polatengin polatengin changed the title [ARM] az bicep: reflecting bicep cli updates to az bicep command [ARM] az bicep: Reflecting bicep cli updates to az bicep command Aug 9, 2023
@polatengin
Copy link
Member Author

Please note that we are launching the release for this sprint this week. Please resolve all comments by tomorrow, otherwise the release of this PR will have to be postponed to the next sprint (on 09-05)

I added tests to the PR, all the pipelines are successfully run now 👍

I also updated the PR description

Can you review this PR, please?

/cc: @zhoxing-ms @yonzhan

@zhoxing-ms
Copy link
Contributor

@polatengin Please note that the parameters do not need to be written in the second command signature section, but should be written in the following description section. And the bicep module belongs to [ARM] instead of [Bicep]
For example:

[Bicep] az bicep build-params --file {parameters.bicepparam} : Generates parameters.json file

Should be

[ARM] az bicep build-params: Add new parameter --file to support generating parameters.json file

@polatengin
Copy link
Member Author

@polatengin Please note that the parameters do not need to be written in the second command signature section, but should be written in the following description section. And the bicep module belongs to [ARM] instead of [Bicep] For example:

[Bicep] az bicep build-params --file {parameters.bicepparam} : Generates parameters.json file

Should be

[ARM] az bicep build-params: Add new parameter --file to support generating parameters.json file

I just updated the description of this PR, can you check please @zhoxing-ms ?

polatengin and others added 3 commits August 17, 2023 21:44
Co-authored-by: Xing Zhou <Zhou.Xing@microsoft.com>
Co-authored-by: Xing Zhou <Zhou.Xing@microsoft.com>
@polatengin
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 26781 in repo Azure/azure-cli

@yonzhan
Copy link
Collaborator

yonzhan commented Aug 25, 2023

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@polatengin
Copy link
Member Author

@zhoxing-ms , @yonzhan I see all the checks are passing 🥳

can you review, please?

@zhoxing-ms
Copy link
Contributor

zhoxing-ms commented Aug 29, 2023

@polatengin Please note that we are launching the release for this sprint this week. Please resolve all comments by tomorrow, otherwise the release of this PR will have to be postponed to the next sprint (on 09-26)

Co-authored-by: Xing Zhou <Zhou.Xing@microsoft.com>
@polatengin
Copy link
Member Author

@polatengin Please note that we are launching the release for this sprint this week. Please resolve all comments by tomorrow, otherwise the release of this PR will have to be postponed to the next sprint (on 09-26)

hey @zhoxing-ms, I resolved all the comments. can you please check the PR and help me to merge it?

@zhoxing-ms zhoxing-ms merged commit 9d207c9 into Azure:dev Aug 30, 2023
@polatengin polatengin deleted the enpolat/bicep_commands branch August 30, 2023 04:27
@bebound
Copy link
Contributor

bebound commented Aug 30, 2023

This PR adds two ScenarioTest, which run the recording test in Test Deb/RPM Package and fails in tests/latest/test_resource.py::BicepDecompileParamsTest::test_bicep_decompile_params_file.

On AMD64, it raises Couldn't find a valid ICU package installed on the system. Please install libicu (or icu-libs) using your package manager and try again.
We run the test in docker, this package is not installed by default. (The ADO Ubuntu 20.04 agent installs libicu-dev by default.)

On ARM64, it raises OSError: [Errno 8] Exec format error: '/root/.azure/bin/bicep'. Test uses ensure_bicep_installation to intall bicep binary. It is not compatible with ARM64 arch, as it downloads the amd64 bicep on arm64 platform. However, user can use --target-platform=linux-arm64/osx-arm64 to install arm64 binary after #24847

Other tests which use bicep binary are live only. A quick fix is to change these tests to live only.


AMD64 error log
2023-08-30T06:54:37.3731392Z tests/latest/test_resource.py::BicepDecompileParamsTest::test_bicep_decompile_params_file FAILED [ 63%]
2023-08-30T06:54:37.3731774Z 
2023-08-30T06:54:37.3732052Z =================================== FAILURES ===================================
2023-08-30T06:54:37.3732380Z __________ BicepDecompileParamsTest.test_bicep_decompile_params_file ___________
2023-08-30T06:54:37.3732724Z self = <azure.cli.testsdk.base.ExecutionResult object at 0x7ff599062e30>
2023-08-30T06:54:37.3733029Z cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7ff599061900>
2023-08-30T06:54:37.3733803Z command = 'bicep decompile-params --file /opt/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/tests/latest/test-params.json'
2023-08-30T06:54:37.3734143Z expect_failure = False
2023-08-30T06:54:37.3734254Z 
2023-08-30T06:54:37.3734528Z     def _in_process_execute(self, cli_ctx, command, expect_failure=False):
2023-08-30T06:54:37.3734815Z         from io import StringIO
2023-08-30T06:54:37.3735089Z         from vcr.errors import CannotOverwriteExistingCassetteException
2023-08-30T06:54:37.3735341Z     
2023-08-30T06:54:37.3735632Z         if command.startswith('az '):
2023-08-30T06:54:37.3735855Z             command = command[3:]
2023-08-30T06:54:37.3736057Z     
2023-08-30T06:54:37.3737731Z         stdout_buf = StringIO()
2023-08-30T06:54:37.3738389Z         logging_buf = StringIO()
2023-08-30T06:54:37.3738592Z         try:
2023-08-30T06:54:37.3738852Z             # issue: stderr cannot be redirect in this form, as a result some failure information
2023-08-30T06:54:37.3739154Z             # is lost when command fails.
2023-08-30T06:54:37.3739442Z >           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0
2023-08-30T06:54:37.3739594Z 
2023-08-30T06:54:37.3740007Z /opt/az/lib/python3.10/site-packages/azure/cli/testsdk/base.py:301: 
2023-08-30T06:54:37.3740311Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2023-08-30T06:54:37.3740716Z /opt/az/lib/python3.10/site-packages/knack/cli.py:245: in invoke
2023-08-30T06:54:37.3740997Z     exit_code = self.exception_handler(ex)
2023-08-30T06:54:37.3741447Z /opt/az/lib/python3.10/site-packages/azure/cli/core/__init__.py:127: in exception_handler
2023-08-30T06:54:37.3741747Z     return handle_exception(ex)
2023-08-30T06:54:37.3741994Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2023-08-30T06:54:37.3742126Z 
2023-08-30T06:54:37.3742822Z ex = UnclassifiedUserFault("Process terminated. Couldn't find a valid ICU package installed on the system. Please install l...l]](<Main>d__3 ByRef)\n   at Bicep.Cli.Program.Main(System.String[])\n   at Bicep.Cli.Program.<Main>(System.String[])")
2023-08-30T06:54:37.3743348Z args = (), kwargs = {}
2023-08-30T06:54:37.3743428Z 
2023-08-30T06:54:37.3743788Z     def _handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
2023-08-30T06:54:37.3744258Z         if isinstance(ex, CannotOverwriteExistingCassetteException):
2023-08-30T06:54:37.3744563Z             # This exception usually caused by a no match HTTP request. This is a product error
2023-08-30T06:54:37.3744841Z             # that is caused by change of SDK invocation.
2023-08-30T06:54:37.3745050Z             raise ex
2023-08-30T06:54:37.3745225Z     
2023-08-30T06:54:37.3745411Z >       raise CliExecutionError(ex)
2023-08-30T06:54:37.3745749Z E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception UnclassifiedUserFault during execution and fails the command.
2023-08-30T06:54:37.3745952Z 
2023-08-30T06:54:37.3746332Z /opt/az/lib/python3.10/site-packages/azure/cli/testsdk/patches.py:35: CliExecutionError
2023-08-30T06:54:37.3746486Z 
2023-08-30T06:54:37.3746704Z During handling of the above exception, another exception occurred:
2023-08-30T06:54:37.3746840Z 
2023-08-30T06:54:37.3747137Z self = <command_modules.resource.tests.latest.test_resource.BicepDecompileParamsTest testMethod=test_bicep_decompile_params_file>
2023-08-30T06:54:37.3747330Z 
2023-08-30T06:54:37.3747527Z     def test_bicep_decompile_params_file(self):
2023-08-30T06:54:37.3747789Z         curr_dir = os.path.dirname(os.path.realpath(__file__))
2023-08-30T06:54:37.3748194Z         tf = os.path.join(curr_dir, 'test-params.json').replace('\\', '\\\\')
2023-08-30T06:54:37.3748629Z         params_path = os.path.join(curr_dir, 'test-params.bicepparam').replace('\\', '\\\\')
2023-08-30T06:54:37.3748899Z         self.kwargs.update({
2023-08-30T06:54:37.3749145Z             'tf': tf,
2023-08-30T06:54:37.3749419Z             'params_path': params_path,
2023-08-30T06:54:37.3749606Z         })
2023-08-30T06:54:37.3749768Z     
2023-08-30T06:54:37.3750059Z >       self.cmd('az bicep decompile-params --file {tf}')
2023-08-30T06:54:37.3750176Z 
2023-08-30T06:54:37.3750588Z /opt/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/tests/latest/test_resource.py:5012: 
2023-08-30T06:54:37.3750901Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2023-08-30T06:54:37.3751280Z /opt/az/lib/python3.10/site-packages/azure/cli/testsdk/base.py:175: in cmd
2023-08-30T06:54:37.3751610Z     return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
2023-08-30T06:54:37.3752063Z /opt/az/lib/python3.10/site-packages/azure/cli/testsdk/base.py:250: in __init__
2023-08-30T06:54:37.3752461Z     self._in_process_execute(cli_ctx, command, expect_failure=expect_failure)
2023-08-30T06:54:37.3752914Z /opt/az/lib/python3.10/site-packages/azure/cli/testsdk/base.py:313: in _in_process_execute
2023-08-30T06:54:37.3753170Z     raise ex.exception
2023-08-30T06:54:37.3753502Z /opt/az/lib/python3.10/site-packages/knack/cli.py:233: in invoke
2023-08-30T06:54:37.3753764Z     cmd_result = self.invocation.execute(args)
2023-08-30T06:54:37.3754201Z /opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py:663: in execute
2023-08-30T06:54:37.3754467Z     raise ex
2023-08-30T06:54:37.3754869Z /opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py:726: in _run_jobs_serially
2023-08-30T06:54:37.3755185Z     results.append(self._run_job(expanded_arg, cmd_copy))
2023-08-30T06:54:37.3755602Z /opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py:697: in _run_job
2023-08-30T06:54:37.3755863Z     result = cmd_copy(params)
2023-08-30T06:54:37.3756250Z /opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py:333: in __call__
2023-08-30T06:54:37.3756538Z     return self.handler(*args, **kwargs)
2023-08-30T06:54:37.3756963Z /opt/az/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py:121: in handler
2023-08-30T06:54:37.3757236Z     return op(**command_args)
2023-08-30T06:54:37.3757688Z /opt/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/custom.py:4381: in decompileparams_bicep_file
2023-08-30T06:54:37.3758116Z     if bicep_version_greater_than_or_equal_to(minimum_supported_version):
2023-08-30T06:54:37.3758643Z /opt/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/_bicep.py:202: in bicep_version_greater_than_or_equal_to
2023-08-30T06:54:37.3758986Z     installed_version = _get_bicep_installed_version(installation_path)
2023-08-30T06:54:37.3759470Z /opt/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/_bicep.py:267: in _get_bicep_installed_version
2023-08-30T06:54:37.3759933Z     installed_version_output = _run_command(bicep_executable_path, ["--version"])
2023-08-30T06:54:37.3760207Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2023-08-30T06:54:37.3760316Z 
2023-08-30T06:54:37.3760646Z bicep_installation_path = '/root/.azure/bin/bicep', args = ['--version']
2023-08-30T06:54:37.3760786Z 
2023-08-30T06:54:37.3760976Z     def _run_command(bicep_installation_path, args):
2023-08-30T06:54:37.3761296Z         process = subprocess.run([rf"{bicep_installation_path}"] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2023-08-30T06:54:37.3761563Z     
2023-08-30T06:54:37.3761720Z         try:
2023-08-30T06:54:37.3761901Z             process.check_returncode()
2023-08-30T06:54:37.3762136Z             command_warnings = process.stderr.decode("utf-8")
2023-08-30T06:54:37.3762359Z             if command_warnings:
2023-08-30T06:54:37.3762571Z                 _logger.warning(command_warnings)
2023-08-30T06:54:37.3762801Z             return process.stdout.decode("utf-8")
2023-08-30T06:54:37.3763040Z         except subprocess.CalledProcessError:
2023-08-30T06:54:37.3805195Z             stderr_output = process.stderr.decode("utf-8")
2023-08-30T06:54:37.3805441Z             errors = []
2023-08-30T06:54:37.3805610Z     
2023-08-30T06:54:37.3805795Z             for line in stderr_output.splitlines():
2023-08-30T06:54:37.3806041Z                 if re.match(_bicep_diagnostic_warning_pattern, line):
2023-08-30T06:54:37.3806267Z                     _logger.warning(line)
2023-08-30T06:54:37.3806464Z                 else:
2023-08-30T06:54:37.3806643Z                     errors.append(line)
2023-08-30T06:54:37.3806813Z     
2023-08-30T06:54:37.3806999Z             error_msg = os.linesep.join(errors)
2023-08-30T06:54:37.3807223Z >           raise UnclassifiedUserFault(error_msg)
2023-08-30T06:54:37.3808254Z E           azure.cli.core.azclierror.UnclassifiedUserFault: Process terminated. Couldn't find a valid ICU package installed on the system. Please install libicu (or icu-libs) using your package manager and try again. Alternatively you can set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support. Please see https://aka.ms/dotnet-missing-libicu for more information.
2023-08-30T06:54:37.3808962Z E              at System.Environment.FailFast(System.String)
2023-08-30T06:54:37.3809225Z E              at System.Globalization.GlobalizationMode+Settings..cctor()
2023-08-30T06:54:37.3809513Z E              at System.Globalization.GlobalizationMode+Settings.get_Invariant()
2023-08-30T06:54:37.3809796Z E              at System.Globalization.GlobalizationMode.get_Invariant()
2023-08-30T06:54:37.3810078Z E              at System.Globalization.CultureData.CreateCultureWithInvariantData()
2023-08-30T06:54:37.3810340Z E              at System.Globalization.CultureData.get_Invariant()
2023-08-30T06:54:37.3810593Z E              at System.Globalization.CultureInfo..cctor()
2023-08-30T06:54:37.3810844Z E              at System.Globalization.CultureInfo.get_CurrentCulture()
2023-08-30T06:54:37.3811114Z E              at System.Globalization.NumberFormatInfo.get_CurrentInfo()
2023-08-30T06:54:37.3811395Z E              at System.Reflection.AssemblyNameParser.ParseVersion(System.String)
2023-08-30T06:54:37.3811674Z E              at System.Reflection.AssemblyNameParser.Parse()
2023-08-30T06:54:37.3811943Z E              at System.Reflection.AssemblyNameParser.Parse(System.ReadOnlySpan`1<Char>)
2023-08-30T06:54:37.3812245Z E              at System.Reflection.AssemblyName.ParseAsAssemblySpec(Char*, Void*)
2023-08-30T06:54:37.3812723Z E              at System.RuntimeTypeHandle.<GetTypeByNameUsingCARules>g____PInvoke|80_0(UInt16*, System.Runtime.CompilerServices.QCallModule, System.Runtime.CompilerServices.ObjectHandleOnStack)
2023-08-30T06:54:37.3813213Z E              at System.RuntimeTypeHandle.<GetTypeByNameUsingCARules>g____PInvoke|80_0(UInt16*, System.Runtime.CompilerServices.QCallModule, System.Runtime.CompilerServices.ObjectHandleOnStack)
2023-08-30T06:54:37.3813710Z E              at System.RuntimeTypeHandle.GetTypeByNameUsingCARules(System.String, System.Runtime.CompilerServices.QCallModule, System.Runtime.CompilerServices.ObjectHandleOnStack)
2023-08-30T06:54:37.3814130Z E              at System.RuntimeTypeHandle.GetTypeByNameUsingCARules(System.String, System.Reflection.RuntimeModule)
2023-08-30T06:54:37.3814502Z E              at System.Reflection.CustomAttributeTypedArgument.ResolveType(System.Reflection.RuntimeModule, System.String)
2023-08-30T06:54:37.3814922Z E              at System.Reflection.CustomAttributeTypedArgument..ctor(System.Reflection.RuntimeModule, System.Reflection.CustomAttributeEncodedArgument)
2023-08-30T06:54:37.3815312Z E              at System.Reflection.RuntimeCustomAttributeData.get_ConstructorArguments()
2023-08-30T06:54:37.3815682Z E              at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetDynamicallyAccessedMemberTypes(System.Type)
2023-08-30T06:54:37.3816120Z E              at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.ValidateTrimmingAnnotations(System.Type, System.Type[], System.Type, System.Type[])
2023-08-30T06:54:37.3816520Z E              at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.Populate()
2023-08-30T06:54:37.3816948Z E              at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory..ctor(System.Collections.Generic.ICollection`1<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>)
2023-08-30T06:54:37.3817511Z E              at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(System.Collections.Generic.ICollection`1<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, Microsoft.Extensions.DependencyInjection.ServiceProviderOptions)
2023-08-30T06:54:37.3818141Z E              at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection, Microsoft.Extensions.DependencyInjection.ServiceProviderOptions)
2023-08-30T06:54:37.3818731Z E              at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)
2023-08-30T06:54:37.3819160Z E              at Microsoft.Extensions.Logging.LoggerFactory.Create(System.Action`1<Microsoft.Extensions.Logging.ILoggingBuilder>)
2023-08-30T06:54:37.3819464Z E              at Bicep.Cli.Program.CreateLoggerFactory(Bicep.Cli.IOContext)
2023-08-30T06:54:37.3819742Z E              at Bicep.Cli.Program.ConfigureServices(Bicep.Cli.IOContext)
2023-08-30T06:54:37.3820076Z E              at Bicep.Cli.Program..ctor(Bicep.Cli.IOContext, System.Action`1<Microsoft.Extensions.DependencyInjection.IServiceCollection>)
2023-08-30T06:54:37.3820374Z E              at Bicep.Cli.Program+<Main>d__3.MoveNext()
2023-08-30T06:54:37.3820716Z E              at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Bicep.Cli.Program+<Main>d__3, bicep, Version=0.20.0.0, Culture=neutral, PublicKeyToken=null]](<Main>d__3 ByRef)
2023-08-30T06:54:37.3821284Z E              at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Bicep.Cli.Program+<Main>d__3, bicep, Version=0.20.0.0, Culture=neutral, PublicKeyToken=null]](<Main>d__3 ByRef)
2023-08-30T06:54:37.3821702Z E              at Bicep.Cli.Program.Main(System.String[])
2023-08-30T06:54:37.3822006Z E              at Bicep.Cli.Program.<Main>(System.String[])
2023-08-30T06:54:37.3822104Z 
2023-08-30T06:54:37.3822557Z /opt/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/_bicep.py:324: UnclassifiedUserFault
ARM64 error log
2023-08-30T06:56:08.9069305Z tests/latest/test_resource.py::BicepDecompileParamsTest::test_bicep_decompile_params_file FAILED [ 63%]
2023-08-30T06:56:08.9069623Z 
2023-08-30T06:56:08.9069889Z =================================== FAILURES ===================================
2023-08-30T06:56:08.9070222Z __________ BicepDecompileParamsTest.test_bicep_decompile_params_file ___________
2023-08-30T06:56:08.9132262Z self = <azure.cli.testsdk.base.ExecutionResult object at 0xffff9226dbd0>
2023-08-30T06:56:08.9132606Z cli_ctx = <azure.cli.core.mock.DummyCli object at 0xffff922b4280>
2023-08-30T06:56:08.9133301Z command = 'bicep decompile-params --file /usr/lib64/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/tests/latest/test-params.json'
2023-08-30T06:56:08.9133640Z expect_failure = False
2023-08-30T06:56:08.9177156Z 
2023-08-30T06:56:08.9177822Z     def _in_process_execute(self, cli_ctx, command, expect_failure=False):
2023-08-30T06:56:08.9178102Z         from io import StringIO
2023-08-30T06:56:08.9178365Z         from vcr.errors import CannotOverwriteExistingCassetteException
2023-08-30T06:56:08.9217096Z     
2023-08-30T06:56:08.9217597Z         if command.startswith('az '):
2023-08-30T06:56:08.9217842Z             command = command[3:]
2023-08-30T06:56:08.9218036Z     
2023-08-30T06:56:08.9218228Z         stdout_buf = StringIO()
2023-08-30T06:56:08.9218457Z         logging_buf = StringIO()
2023-08-30T06:56:08.9218655Z         try:
2023-08-30T06:56:08.9218914Z             # issue: stderr cannot be redirect in this form, as a result some failure information
2023-08-30T06:56:08.9219191Z             # is lost when command fails.
2023-08-30T06:56:08.9219469Z >           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0
2023-08-30T06:56:08.9219614Z 
2023-08-30T06:56:08.9219983Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/testsdk/base.py:301: 
2023-08-30T06:56:08.9220292Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2023-08-30T06:56:08.9220672Z /usr/lib64/az/lib/python3.10/site-packages/knack/cli.py:245: in invoke
2023-08-30T06:56:08.9220958Z     exit_code = self.exception_handler(ex)
2023-08-30T06:56:08.9221372Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/core/__init__.py:127: in exception_handler
2023-08-30T06:56:08.9221667Z     return handle_exception(ex)
2023-08-30T06:56:08.9221921Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2023-08-30T06:56:08.9222033Z 
2023-08-30T06:56:08.9222334Z ex = OSError(8, 'Exec format error'), args = (), kwargs = {}
2023-08-30T06:56:08.9222465Z 
2023-08-30T06:56:08.9222828Z     def _handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
2023-08-30T06:56:08.9223146Z         if isinstance(ex, CannotOverwriteExistingCassetteException):
2023-08-30T06:56:08.9223453Z             # This exception usually caused by a no match HTTP request. This is a product error
2023-08-30T06:56:08.9224064Z             # that is caused by change of SDK invocation.
2023-08-30T06:56:08.9224280Z             raise ex
2023-08-30T06:56:08.9224458Z     
2023-08-30T06:56:08.9224657Z >       raise CliExecutionError(ex)
2023-08-30T06:56:08.9224973Z E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception OSError during execution and fails the command.
2023-08-30T06:56:08.9225320Z 
2023-08-30T06:56:08.9225710Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/testsdk/patches.py:35: CliExecutionError
2023-08-30T06:56:08.9225869Z 
2023-08-30T06:56:08.9226105Z During handling of the above exception, another exception occurred:
2023-08-30T06:56:08.9226236Z 
2023-08-30T06:56:08.9226532Z self = <command_modules.resource.tests.latest.test_resource.BicepDecompileParamsTest testMethod=test_bicep_decompile_params_file>
2023-08-30T06:56:08.9226728Z 
2023-08-30T06:56:08.9226939Z     def test_bicep_decompile_params_file(self):
2023-08-30T06:56:08.9227264Z         curr_dir = os.path.dirname(os.path.realpath(__file__))
2023-08-30T06:56:08.9227651Z         tf = os.path.join(curr_dir, 'test-params.json').replace('\\', '\\\\')
2023-08-30T06:56:08.9228075Z         params_path = os.path.join(curr_dir, 'test-params.bicepparam').replace('\\', '\\\\')
2023-08-30T06:56:08.9228350Z         self.kwargs.update({
2023-08-30T06:56:08.9228596Z             'tf': tf,
2023-08-30T06:56:08.9228896Z             'params_path': params_path,
2023-08-30T06:56:08.9229104Z         })
2023-08-30T06:56:08.9229279Z     
2023-08-30T06:56:08.9229578Z >       self.cmd('az bicep decompile-params --file {tf}')
2023-08-30T06:56:08.9229700Z 
2023-08-30T06:56:08.9230120Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/tests/latest/test_resource.py:5012: 
2023-08-30T06:56:08.9230454Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2023-08-30T06:56:08.9230843Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/testsdk/base.py:175: in cmd
2023-08-30T06:56:08.9231203Z     return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
2023-08-30T06:56:08.9233794Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/testsdk/base.py:250: in __init__
2023-08-30T06:56:08.9234262Z     self._in_process_execute(cli_ctx, command, expect_failure=expect_failure)
2023-08-30T06:56:08.9234712Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/testsdk/base.py:313: in _in_process_execute
2023-08-30T06:56:08.9235002Z     raise ex.exception
2023-08-30T06:56:08.9235358Z /usr/lib64/az/lib/python3.10/site-packages/knack/cli.py:233: in invoke
2023-08-30T06:56:08.9235650Z     cmd_result = self.invocation.execute(args)
2023-08-30T06:56:08.9236064Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py:663: in execute
2023-08-30T06:56:08.9236331Z     raise ex
2023-08-30T06:56:08.9236736Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py:726: in _run_jobs_serially
2023-08-30T06:56:08.9237063Z     results.append(self._run_job(expanded_arg, cmd_copy))
2023-08-30T06:56:08.9237491Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py:697: in _run_job
2023-08-30T06:56:08.9237784Z     result = cmd_copy(params)
2023-08-30T06:56:08.9238178Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py:333: in __call__
2023-08-30T06:56:08.9238483Z     return self.handler(*args, **kwargs)
2023-08-30T06:56:08.9238912Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py:121: in handler
2023-08-30T06:56:08.9239216Z     return op(**command_args)
2023-08-30T06:56:08.9239656Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/custom.py:4381: in decompileparams_bicep_file
2023-08-30T06:56:08.9240022Z     if bicep_version_greater_than_or_equal_to(minimum_supported_version):
2023-08-30T06:56:08.9240534Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/_bicep.py:202: in bicep_version_greater_than_or_equal_to
2023-08-30T06:56:08.9241130Z     installed_version = _get_bicep_installed_version(installation_path)
2023-08-30T06:56:08.9241617Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/_bicep.py:267: in _get_bicep_installed_version
2023-08-30T06:56:08.9242085Z     installed_version_output = _run_command(bicep_executable_path, ["--version"])
2023-08-30T06:56:08.9242679Z /usr/lib64/az/lib/python3.10/site-packages/azure/cli/command_modules/resource/_bicep.py:305: in _run_command
2023-08-30T06:56:08.9243070Z     process = subprocess.run([rf"{bicep_installation_path}"] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2023-08-30T06:56:08.9243391Z /usr/lib64/python3.10/subprocess.py:503: in run
2023-08-30T06:56:08.9243647Z     with Popen(*popenargs, **kwargs) as process:
2023-08-30T06:56:08.9243910Z /usr/lib64/python3.10/subprocess.py:971: in __init__
2023-08-30T06:56:08.9244192Z     self._execute_child(args, executable, preexec_fn, close_fds,
2023-08-30T06:56:08.9244474Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2023-08-30T06:56:08.9244588Z 
2023-08-30T06:56:08.9244918Z self = <Popen: returncode: 255 args: ['/root/.azure/bin/bicep', '--version']>
2023-08-30T06:56:08.9245294Z args = ['/root/.azure/bin/bicep', '--version']
2023-08-30T06:56:08.9245672Z executable = b'/root/.azure/bin/bicep', preexec_fn = None, close_fds = True
2023-08-30T06:56:08.9245992Z pass_fds = (), cwd = None, env = None, startupinfo = None, creationflags = 0
2023-08-30T06:56:08.9246387Z shell = False, p2cread = -1, p2cwrite = -1, c2pread = 17, c2pwrite = 18
2023-08-30T06:56:08.9246693Z errread = 19, errwrite = 20, restore_signals = True, gid = None, gids = None
2023-08-30T06:56:08.9247056Z uid = None, umask = -1, start_new_session = False
2023-08-30T06:56:08.9247167Z 
2023-08-30T06:56:08.9247405Z     def _execute_child(self, args, executable, preexec_fn, close_fds,
2023-08-30T06:56:08.9247660Z                        pass_fds, cwd, env,
2023-08-30T06:56:08.9247893Z                        startupinfo, creationflags, shell,
2023-08-30T06:56:08.9248121Z                        p2cread, p2cwrite,
2023-08-30T06:56:08.9248332Z                        c2pread, c2pwrite,
2023-08-30T06:56:08.9248541Z                        errread, errwrite,
2023-08-30T06:56:08.9248749Z                        restore_signals,
2023-08-30T06:56:08.9248964Z                        gid, gids, uid, umask,
2023-08-30T06:56:08.9249184Z                        start_new_session):
2023-08-30T06:56:08.9249406Z         """Execute program (POSIX version)"""
2023-08-30T06:56:08.9249607Z     
2023-08-30T06:56:08.9249809Z         if isinstance(args, (str, bytes)):
2023-08-30T06:56:08.9250022Z             args = [args]
2023-08-30T06:56:08.9250239Z         elif isinstance(args, os.PathLike):
2023-08-30T06:56:08.9250452Z             if shell:
2023-08-30T06:56:08.9250782Z                 raise TypeError('path-like args is not allowed when '
2023-08-30T06:56:08.9251105Z                                 'shell is true')
2023-08-30T06:56:08.9251309Z             args = [args]
2023-08-30T06:56:08.9251498Z         else:
2023-08-30T06:56:08.9251692Z             args = list(args)
2023-08-30T06:56:08.9251878Z     
2023-08-30T06:56:08.9252056Z         if shell:
2023-08-30T06:56:08.9252374Z             # On Android the default shell is at '/system/bin/sh'.
2023-08-30T06:56:08.9252703Z             unix_shell = ('/system/bin/sh' if
2023-08-30T06:56:08.9253054Z                       hasattr(sys, 'getandroidapilevel') else '/bin/sh')
2023-08-30T06:56:08.9253378Z             args = [unix_shell, "-c"] + args
2023-08-30T06:56:08.9253602Z             if executable:
2023-08-30T06:56:08.9253807Z                 args[0] = executable
2023-08-30T06:56:08.9253998Z     
2023-08-30T06:56:08.9254186Z         if executable is None:
2023-08-30T06:56:08.9254394Z             executable = args[0]
2023-08-30T06:56:08.9254584Z     
2023-08-30T06:56:08.9254811Z         sys.audit("subprocess.Popen", executable, args, cwd, env)
2023-08-30T06:56:08.9255236Z     
2023-08-30T06:56:08.9255422Z         if (_USE_POSIX_SPAWN
2023-08-30T06:56:08.9255647Z                 and os.path.dirname(executable)
2023-08-30T06:56:08.9255871Z                 and preexec_fn is None
2023-08-30T06:56:08.9256078Z                 and not close_fds
2023-08-30T06:56:08.9256810Z                 and not pass_fds
2023-08-30T06:56:08.9257020Z                 and cwd is None
2023-08-30T06:56:08.9257488Z                 and (p2cread == -1 or p2cread > 2)
2023-08-30T06:56:08.9257810Z                 and (c2pwrite == -1 or c2pwrite > 2)
2023-08-30T06:56:08.9258132Z                 and (errwrite == -1 or errwrite > 2)
2023-08-30T06:56:08.9258371Z                 and not start_new_session
2023-08-30T06:56:08.9258583Z                 and gid is None
2023-08-30T06:56:08.9258782Z                 and gids is None
2023-08-30T06:56:08.9258982Z                 and uid is None
2023-08-30T06:56:08.9259180Z                 and umask < 0):
2023-08-30T06:56:08.9259433Z             self._posix_spawn(args, executable, env, restore_signals,
2023-08-30T06:56:08.9259684Z                               p2cread, p2cwrite,
2023-08-30T06:56:08.9259901Z                               c2pread, c2pwrite,
2023-08-30T06:56:08.9260109Z                               errread, errwrite)
2023-08-30T06:56:08.9260309Z             return
2023-08-30T06:56:08.9260491Z     
2023-08-30T06:56:08.9260689Z         orig_executable = executable
2023-08-30T06:56:08.9260890Z     
2023-08-30T06:56:08.9261122Z         # For transferring possible exec failure from child to parent.
2023-08-30T06:56:08.9261415Z         # Data format: "exception name:hex errno:description"
2023-08-30T06:56:08.9261843Z         # Pickle is not used; it is complex and involves memory allocation.
2023-08-30T06:56:08.9262115Z         errpipe_read, errpipe_write = os.pipe()
2023-08-30T06:56:08.9262383Z         # errpipe_write must not be in the standard io 0, 1, or 2 fd range.
2023-08-30T06:56:08.9262627Z         low_fds_to_close = []
2023-08-30T06:56:08.9262844Z         while errpipe_write < 3:
2023-08-30T06:56:08.9263076Z             low_fds_to_close.append(errpipe_write)
2023-08-30T06:56:08.9263325Z             errpipe_write = os.dup(errpipe_write)
2023-08-30T06:56:08.9263562Z         for low_fd in low_fds_to_close:
2023-08-30T06:56:08.9263781Z             os.close(low_fd)
2023-08-30T06:56:08.9263976Z         try:
2023-08-30T06:56:08.9264157Z             try:
2023-08-30T06:56:08.9264383Z                 # We must avoid complex work that could involve
2023-08-30T06:56:08.9264644Z                 # malloc or free in the child process to avoid
2023-08-30T06:56:08.9264904Z                 # potential deadlocks, thus we do all this here.
2023-08-30T06:56:08.9265147Z                 # and pass it to fork_exec()
2023-08-30T06:56:08.9265344Z     
2023-08-30T06:56:08.9265534Z                 if env is not None:
2023-08-30T06:56:08.9265728Z                     env_list = []
2023-08-30T06:56:08.9265938Z                     for k, v in env.items():
2023-08-30T06:56:08.9266157Z                         k = os.fsencode(k)
2023-08-30T06:56:08.9266440Z                         if b'=' in k:
2023-08-30T06:56:08.9266688Z                             raise ValueError("illegal environment variable name")
2023-08-30T06:56:08.9267043Z                         env_list.append(k + b'=' + os.fsencode(v))
2023-08-30T06:56:08.9267271Z                 else:
2023-08-30T06:56:08.9267496Z                     env_list = None  # Use execv instead of execve.
2023-08-30T06:56:08.9267751Z                 executable = os.fsencode(executable)
2023-08-30T06:56:08.9267993Z                 if os.path.dirname(executable):
2023-08-30T06:56:08.9268228Z                     executable_list = (executable,)
2023-08-30T06:56:08.9268437Z                 else:
2023-08-30T06:56:08.9268661Z                     # This matches the behavior of os._execvpe().
2023-08-30T06:56:08.9268899Z                     executable_list = tuple(
2023-08-30T06:56:08.9269142Z                         os.path.join(os.fsencode(dir), executable)
2023-08-30T06:56:08.9269591Z                         for dir in os.get_exec_path(env))
2023-08-30T06:56:08.9269824Z                 fds_to_keep = set(pass_fds)
2023-08-30T06:56:08.9270052Z                 fds_to_keep.add(errpipe_write)
2023-08-30T06:56:08.9270293Z                 self.pid = _posixsubprocess.fork_exec(
2023-08-30T06:56:08.9270528Z                         args, executable_list,
2023-08-30T06:56:08.9270893Z                         close_fds, tuple(sorted(map(int, fds_to_keep))),
2023-08-30T06:56:08.9271120Z                         cwd, env_list,
2023-08-30T06:56:08.9271347Z                         p2cread, p2cwrite, c2pread, c2pwrite,
2023-08-30T06:56:08.9271576Z                         errread, errwrite,
2023-08-30T06:56:08.9271796Z                         errpipe_read, errpipe_write,
2023-08-30T06:56:08.9272034Z                         restore_signals, start_new_session,
2023-08-30T06:56:08.9272267Z                         gid, gids, uid, umask,
2023-08-30T06:56:08.9272475Z                         preexec_fn)
2023-08-30T06:56:08.9272690Z                 self._child_created = True
2023-08-30T06:56:08.9272894Z             finally:
2023-08-30T06:56:08.9273113Z                 # be sure the FD is closed no matter what
2023-08-30T06:56:08.9273339Z                 os.close(errpipe_write)
2023-08-30T06:56:08.9273533Z     
2023-08-30T06:56:08.9273742Z             self._close_pipe_fds(p2cread, p2cwrite,
2023-08-30T06:56:08.9273979Z                                  c2pread, c2pwrite,
2023-08-30T06:56:08.9274193Z                                  errread, errwrite)
2023-08-30T06:56:08.9274381Z     
2023-08-30T06:56:08.9274604Z             # Wait for exec to fail or succeed; possibly raising an
2023-08-30T06:56:08.9274847Z             # exception (limited in size)
2023-08-30T06:56:08.9275065Z             errpipe_data = bytearray()
2023-08-30T06:56:08.9275263Z             while True:
2023-08-30T06:56:08.9275481Z                 part = os.read(errpipe_read, 50000)
2023-08-30T06:56:08.9275708Z                 errpipe_data += part
2023-08-30T06:56:08.9275937Z                 if not part or len(errpipe_data) > 50000:
2023-08-30T06:56:08.9276147Z                     break
2023-08-30T06:56:08.9276333Z         finally:
2023-08-30T06:56:08.9276548Z             # be sure the FD is closed no matter what
2023-08-30T06:56:08.9276776Z             os.close(errpipe_read)
2023-08-30T06:56:08.9276967Z     
2023-08-30T06:56:08.9277151Z         if errpipe_data:
2023-08-30T06:56:08.9277345Z             try:
2023-08-30T06:56:08.9277554Z                 pid, sts = os.waitpid(self.pid, 0)
2023-08-30T06:56:08.9277773Z                 if pid == self.pid:
2023-08-30T06:56:08.9277993Z                     self._handle_exitstatus(sts)
2023-08-30T06:56:08.9278198Z                 else:
2023-08-30T06:56:08.9278406Z                     self.returncode = sys.maxsize
2023-08-30T06:56:08.9278630Z             except ChildProcessError:
2023-08-30T06:56:08.9278821Z                 pass
2023-08-30T06:56:08.9279001Z     
2023-08-30T06:56:08.9279176Z             try:
2023-08-30T06:56:08.9279390Z                 exception_name, hex_errno, err_msg = (
2023-08-30T06:56:08.9279755Z                         errpipe_data.split(b':', 2))
2023-08-30T06:56:08.9280023Z                 # The encoding here should match the encoding
2023-08-30T06:56:08.9280278Z                 # written in by the subprocess implementations
2023-08-30T06:56:08.9280514Z                 # like _posixsubprocess
2023-08-30T06:56:08.9280736Z                 err_msg = err_msg.decode()
2023-08-30T06:56:08.9280949Z             except ValueError:
2023-08-30T06:56:08.9281253Z                 exception_name = b'SubprocessError'
2023-08-30T06:56:08.9281480Z                 hex_errno = b'0'
2023-08-30T06:56:08.9281807Z                 err_msg = 'Bad exception data from child: {!r}'.format(
2023-08-30T06:56:08.9282063Z                               bytes(errpipe_data))
2023-08-30T06:56:08.9282292Z             child_exception_type = getattr(
2023-08-30T06:56:08.9282780Z                     builtins, exception_name.decode('ascii'),
2023-08-30T06:56:08.9283022Z                     SubprocessError)
2023-08-30T06:56:08.9283273Z             if issubclass(child_exception_type, OSError) and hex_errno:
2023-08-30T06:56:08.9283534Z                 errno_num = int(hex_errno, 16)
2023-08-30T06:56:08.9283775Z                 child_exec_never_called = (err_msg == "noexec")
2023-08-30T06:56:08.9284018Z                 if child_exec_never_called:
2023-08-30T06:56:08.9284360Z                     err_msg = ""
2023-08-30T06:56:08.9284580Z                     # The error must be from chdir(cwd).
2023-08-30T06:56:08.9284803Z                     err_filename = cwd
2023-08-30T06:56:08.9284999Z                 else:
2023-08-30T06:56:08.9285209Z                     err_filename = orig_executable
2023-08-30T06:56:08.9285425Z                 if errno_num != 0:
2023-08-30T06:56:08.9285647Z                     err_msg = os.strerror(errno_num)
2023-08-30T06:56:08.9285909Z >               raise child_exception_type(errno_num, err_msg, err_filename)
2023-08-30T06:56:08.9286298Z E               OSError: [Errno 8] Exec format error: '/root/.azure/bin/bicep'
2023-08-30T06:56:08.9286423Z 
2023-08-30T06:56:08.9286650Z /usr/lib64/python3.10/subprocess.py:1863: OSError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ARM az resource/group/lock/tag/deployment/policy/managementapp/account management-group Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants