@@ -4235,7 +4235,131 @@ def test_resource_deployment_with_bicepparam_and_other_parameter_sources(self):
42354235
42364236 with self .assertRaisesRegex (CLIError , "Can" ):
42374237 self .cmd ('deployment group create --resource-group {rg} --template-file "{tf}" --parameters {params1} --parameters {params2}' )
4238-
4238+
4239+ def test_is_using_none_bicepparam_file (self ):
4240+ from azure .cli .command_modules .resource ._bicep import is_using_none_bicepparam_file
4241+ import tempfile
4242+
4243+ def _write_temp (content ):
4244+ f = tempfile .NamedTemporaryFile (mode = 'w' , suffix = '.bicepparam' , delete = False )
4245+ f .write (content )
4246+ f .close ()
4247+ return f .name
4248+
4249+ # Basic 'using none'
4250+ path = _write_temp ("using none\n param location = 'westus2'\n " )
4251+ self .assertTrue (is_using_none_bicepparam_file (path ))
4252+ os .unlink (path )
4253+
4254+ # With leading comments
4255+ path = _write_temp ("// comment\n // another\n using none\n param location = 'westus2'\n " )
4256+ self .assertTrue (is_using_none_bicepparam_file (path ))
4257+ os .unlink (path )
4258+
4259+ # With leading blank lines
4260+ path = _write_temp ("\n \n \n using none\n param location = 'westus2'\n " )
4261+ self .assertTrue (is_using_none_bicepparam_file (path ))
4262+ os .unlink (path )
4263+
4264+ # Case insensitive
4265+ path = _write_temp ("Using None\n param location = 'westus2'\n " )
4266+ self .assertTrue (is_using_none_bicepparam_file (path ))
4267+ os .unlink (path )
4268+
4269+ path = _write_temp ("USING NONE\n param location = 'westus2'\n " )
4270+ self .assertTrue (is_using_none_bicepparam_file (path ))
4271+ os .unlink (path )
4272+
4273+ # Normal using declaration
4274+ path = _write_temp ("using './main.bicep'\n param location = 'westus2'\n " )
4275+ self .assertFalse (is_using_none_bicepparam_file (path ))
4276+ os .unlink (path )
4277+
4278+ # Using with another path
4279+ path = _write_temp ("using 'other.bicep'\n param location = 'westus2'\n " )
4280+ self .assertFalse (is_using_none_bicepparam_file (path ))
4281+ os .unlink (path )
4282+
4283+ # Non-existent file
4284+ self .assertFalse (is_using_none_bicepparam_file ('/nonexistent/path.bicepparam' ))
4285+
4286+ @ResourceGroupPreparer (name_prefix = 'cli_test_deployment_with_bicepparam_using_none' )
4287+ def test_resource_group_level_deployment_with_bicepparam_using_none (self ):
4288+ curr_dir = os .path .dirname (os .path .realpath (__file__ ))
4289+ self .kwargs .update ({
4290+ 'tf' : os .path .join (curr_dir , 'data\\ bicepparam\\ storage_account_template.bicep' ).replace ('\\ ' , '\\ \\ ' ),
4291+ 'params' : os .path .join (curr_dir , 'data\\ bicepparam\\ using_none_params.bicepparam' ).replace ('\\ ' , '\\ \\ ' )
4292+ })
4293+
4294+ self .cmd ('deployment group validate --resource-group {rg} --template-file "{tf}" --parameters {params}' , checks = [
4295+ self .check ('properties.provisioningState' , 'Succeeded' )
4296+ ])
4297+
4298+ self .cmd ('deployment group what-if --resource-group {rg} --template-file "{tf}" --parameters {params} --no-pretty-print' , checks = [
4299+ self .check ('status' , 'Succeeded' ),
4300+ ])
4301+
4302+ self .cmd ('deployment group create --resource-group {rg} --template-file "{tf}" --parameters {params}' , checks = [
4303+ self .check ('properties.provisioningState' , 'Succeeded' )
4304+ ])
4305+
4306+ def test_resource_deployment_with_bicepparam_using_none_and_no_template (self ):
4307+ import tempfile
4308+
4309+ f = tempfile .NamedTemporaryFile (mode = 'w' , suffix = '.bicepparam' , delete = False )
4310+ f .write ("using none\n param location = 'westus2'\n " )
4311+ f .close ()
4312+
4313+ self .kwargs .update ({
4314+ 'rg' : "exampleGroup" ,
4315+ 'params' : f .name
4316+ })
4317+
4318+ # The CLI argument validator requires --template-file, --template-uri, or --template-spec,
4319+ # so omitting all of them fails before reaching the bicepparam logic.
4320+ with self .assertRaisesRegex (CLIError , "Chose only one of" ):
4321+ self .cmd ('deployment group create --resource-group {rg} --parameters {params}' )
4322+
4323+ os .unlink (f .name )
4324+
4325+ def test_resource_deployment_with_bicepparam_using_none_and_multiple_params (self ):
4326+ import tempfile
4327+
4328+ f = tempfile .NamedTemporaryFile (mode = 'w' , suffix = '.bicepparam' , delete = False )
4329+ f .write ("using none\n param location = 'westus2'\n " )
4330+ f .close ()
4331+
4332+ self .kwargs .update ({
4333+ 'rg' : "exampleGroup" ,
4334+ 'tf' : "./main.bicep" ,
4335+ 'params1' : f .name ,
4336+ 'params2' : "./other.json" ,
4337+ })
4338+
4339+ with self .assertRaisesRegex (CLIError , "Can not use --parameters argument more than once when using a .bicepparam file" ):
4340+ self .cmd ('deployment group create --resource-group {rg} --template-file "{tf}" --parameters {params1} --parameters {params2}' )
4341+
4342+ os .unlink (f .name )
4343+
4344+ def test_resource_deployment_with_bicepparam_and_json_template_still_fails_without_using_none (self ):
4345+ """Ensure existing behavior: non-using-none bicepparam + .json template still errors."""
4346+ import tempfile
4347+
4348+ f = tempfile .NamedTemporaryFile (mode = 'w' , suffix = '.bicepparam' , delete = False )
4349+ f .write ("using './something.bicep'\n param location = 'westus2'\n " )
4350+ f .close ()
4351+
4352+ self .kwargs .update ({
4353+ 'rg' : "exampleGroup" ,
4354+ 'tf' : "./main.json" ,
4355+ 'params' : f .name
4356+ })
4357+
4358+ with self .assertRaisesRegex (CLIError , "Only a .bicep template is allowed with a .bicepparam parameter file" ):
4359+ self .cmd ('deployment group create --resource-group {rg} --template-file "{tf}" --parameters {params}' )
4360+
4361+ os .unlink (f .name )
4362+
42394363 def test_subscription_level_deployment_with_bicep (self ):
42404364 curr_dir = os .path .dirname (os .path .realpath (__file__ ))
42414365 self .kwargs .update ({
0 commit comments