Skip to content

Commit 7e5a491

Browse files
author
Hovsep
committed
Merge pull request Azure#2184 from TianoMS/dev
Fix issue #674, Azure#1221, #270
2 parents 94dc2bd + 861cb19 commit 7e5a491

File tree

6 files changed

+61
-83
lines changed

6 files changed

+61
-83
lines changed

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Extensions/JTokenExtensions.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ internal static PSObject ToPsObject(this JToken jtoken, string objectType = null
7373
foreach (var property in jobject.Properties())
7474
{
7575
psObject.Properties.Add(new PSNoteProperty(
76-
name: JTokenExtensions.ConvertToPascalCase(propertyName: property.Name),
76+
name: property.Name,
7777
value: JTokenExtensions.ConvertPropertyValueForPsObject(propertyValue: property.Value)));
7878
}
7979

@@ -126,16 +126,5 @@ internal static object ConvertPropertyValueForPsObject(JToken propertyValue)
126126

127127
return propertyValue.ToString();
128128
}
129-
130-
/// <summary>
131-
/// Converts the property names from camel case to Pascal case.
132-
/// </summary>
133-
/// <param name="propertyName">The name of the property.</param>
134-
private static string ConvertToPascalCase(string propertyName)
135-
{
136-
return char.IsLower(propertyName.First())
137-
? new string(char.ToUpper(propertyName.First()).AsArray().Concat(propertyName.Skip(1)).ToArray())
138-
: propertyName;
139-
}
140129
}
141130
}

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Resource/NewAzureResourceCmdlet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public sealed class NewAzureResourceCmdlet : ResourceManipulationCmdletBase
4949
/// Gets or sets the property object.
5050
/// </summary>
5151
[Alias("PropertyObject")]
52-
[Parameter(Mandatory = true, HelpMessage = "A hash table which represents resource properties.")]
52+
[Parameter(Mandatory = false, HelpMessage = "A hash table which represents resource properties.")]
5353
[ValidateNotNullOrEmpty]
5454
public PSObject Properties { get; set; }
5555

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/ResourceTests.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,14 @@ function Test-SetAResource
261261
# Test
262262
New-AzureRmResourceGroup -Name $rgname -Location $rglocation
263263
$resource = New-AzureRmResource -Name $rname -Location $rglocation -Tags @{Name = "testtag"; Value = "testval"} -ResourceGroupName $rgname -ResourceType $resourceType -PropertyObject @{"key" = "value"} -SkuObject @{ Name = "A0" } -ApiVersion $apiversion -Force
264+
265+
# Verify original value
266+
$oldSku = $resource.Sku.psobject
267+
$oldSkuNameProperty = $oldSku.Properties
268+
Assert-AreEqual $oldSkuNameProperty.Name "name"
269+
Assert-AreEqual $resource.SKu.Name "A0"
270+
271+
# Set resource
264272
Set-AzureRmResource -ResourceGroupName $rgname -ResourceName $rname -ResourceType $resourceType -Properties @{"key2" = "value2"} -Force
265273
Set-AzureRmResource -ResourceGroupName $rgname -ResourceName $rname -ResourceType $resourceType -SkuObject @{ Name = "A1" } -Force
266274

@@ -346,6 +354,9 @@ function Test-GetResourceExpandProperties
346354
$resourceGet = Get-AzureRmResource -ResourceName $rname -ResourceGroupName $rgname -ExpandProperties
347355

348356
# Assert
357+
$properties = $resourceGet.Properties.psobject
358+
$keyProperty = $properties.Properties
359+
Assert-AreEqual $keyProperty.Name "key"
349360
Assert-AreEqual $resourceGet.Properties.key "value"
350361
}
351362

src/ResourceManager/Resources/Commands.Resources/Microsoft.Azure.Commands.Resources.dll-Help.xml

Lines changed: 47 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4431,6 +4431,13 @@ Resources</dev:code>
44314431
</maml:description>
44324432
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
44334433
</command:parameter>
4434+
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4435+
<maml:name>TemplateFile</maml:name>
4436+
<maml:description>
4437+
<maml:para>Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file.</maml:para>
4438+
</maml:description>
4439+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
4440+
</command:parameter>
44344441
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
44354442
<maml:name>Profile</maml:name>
44364443
<maml:description>
@@ -4455,13 +4462,6 @@ Resources</dev:code>
44554462
</maml:description>
44564463
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
44574464
</command:parameter>
4458-
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4459-
<maml:name>TemplateParameterObject</maml:name>
4460-
<maml:description>
4461-
<maml:para>Specifies a hash table of template parameter names and values. This parameter is optional. For help with hash tables in Windows PowerShell, type: Get-Help about_Hash_Tables.If a template has parameters, you must specify parameter values, but you can use this parameter or the TemplateParameterObject parameter. Also, the template parameters are added to the command dynamically when you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required parameter, the cmdlet prompts you for the value.</maml:para>
4462-
</maml:description>
4463-
<command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue>
4464-
</command:parameter>
44654465
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
44664466
<maml:name>TemplateUri</maml:name>
44674467
<maml:description>
@@ -4501,9 +4501,9 @@ Resources</dev:code>
45014501
<command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue>
45024502
</command:parameter>
45034503
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4504-
<maml:name>TemplateFile</maml:name>
4504+
<maml:name>TemplateUri</maml:name>
45054505
<maml:description>
4506-
<maml:para>Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file.</maml:para>
4506+
<maml:para>Specifies the URI of a JSON template file. This file can be a custom template or a gallery template that is saved as a JSON file.</maml:para>
45074507
</maml:description>
45084508
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
45094509
</command:parameter>
@@ -4538,34 +4538,10 @@ Resources</dev:code>
45384538
</maml:description>
45394539
<command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue>
45404540
</command:parameter>
4541-
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
4542-
<maml:name>Profile</maml:name>
4543-
<maml:description>
4544-
<maml:para />
4545-
</maml:description>
4546-
<command:parameterValue required="true" variableLength="false">AzureProfile</command:parameterValue>
4547-
</command:parameter>
4548-
</command:syntaxItem>
4549-
<command:syntaxItem>
4550-
<maml:name>New-AzureRmResourceGroupDeployment</maml:name>
4551-
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4552-
<maml:name>Name</maml:name>
4553-
<maml:description>
4554-
<maml:para>Specifies the name of the deployment project for the resource group. Use -Name or its alias -DeploymentName. This parameter is optional. The default value is the template name without the .json file name extension.</maml:para>
4555-
</maml:description>
4556-
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
4557-
</command:parameter>
4558-
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4559-
<maml:name>ResourceGroupName</maml:name>
4560-
<maml:description>
4561-
<maml:para>Specifies the name of the resource group to which this deployment is added. This parameter is required. If the resource group does not exist, the command fails.</maml:para>
4562-
</maml:description>
4563-
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
4564-
</command:parameter>
45654541
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4566-
<maml:name>TemplateParameterFile</maml:name>
4542+
<maml:name>TemplateFile</maml:name>
45674543
<maml:description>
4568-
<maml:para>Specifies the path and name of a JSON file with the names and values of the template parameters. This parameter is optional.If a template has parameters, you must specify parameter values, but you can use this parameter or the TemplateParameterObject parameter. Also, the template parameters are added to the command dynamically when you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required parameter, the cmdlet prompts you for the value.</maml:para>
4544+
<maml:para>Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file.</maml:para>
45694545
</maml:description>
45704546
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
45714547
</command:parameter>
@@ -4669,34 +4645,17 @@ Resources</dev:code>
46694645
</maml:description>
46704646
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
46714647
</command:parameter>
4672-
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
4673-
<maml:name>Profile</maml:name>
4674-
<maml:description>
4675-
<maml:para />
4676-
</maml:description>
4677-
<command:parameterValue required="true" variableLength="false">AzureProfile</command:parameterValue>
4678-
</command:parameter>
4679-
</command:syntaxItem>
4680-
<command:syntaxItem>
4681-
<maml:name>New-AzureRmResourceGroupDeployment</maml:name>
4682-
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4683-
<maml:name>Name</maml:name>
4684-
<maml:description>
4685-
<maml:para>Specifies the name of the deployment project for the resource group. Use -Name or its alias -DeploymentName. This parameter is optional. The default value is the template name without the .json file name extension.</maml:para>
4686-
</maml:description>
4687-
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
4688-
</command:parameter>
46894648
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4690-
<maml:name>ResourceGroupName</maml:name>
4649+
<maml:name>TemplateParameterUri</maml:name>
46914650
<maml:description>
4692-
<maml:para>Specifies the name of the resource group to which this deployment is added. This parameter is required. If the resource group does not exist, the command fails.</maml:para>
4651+
<maml:para>Specifies the URI of a JSON template parameter file. This file includes all the parameters for the template.</maml:para>
46934652
</maml:description>
46944653
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
46954654
</command:parameter>
46964655
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4697-
<maml:name>TemplateFile</maml:name>
4656+
<maml:name>TemplateUri</maml:name>
46984657
<maml:description>
4699-
<maml:para>Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file.</maml:para>
4658+
<maml:para>Specifies the URI of a JSON template file. This file can be a custom template or a gallery template that is saved as a JSON file.</maml:para>
47004659
</maml:description>
47014660
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
47024661
</command:parameter>
@@ -4725,9 +4684,16 @@ Resources</dev:code>
47254684
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
47264685
</command:parameter>
47274686
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4728-
<maml:name>TemplateUri</maml:name>
4687+
<maml:name>TemplateParameterUri</maml:name>
47294688
<maml:description>
4730-
<maml:para>Specifies the URI of a JSON template file. This file can be a custom template or a gallery template that is saved as a JSON file.</maml:para>
4689+
<maml:para>Specifies the URI of a JSON template parameter file. This file includes all the parameters for the template.</maml:para>
4690+
</maml:description>
4691+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
4692+
</command:parameter>
4693+
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4694+
<maml:name>TemplateFile</maml:name>
4695+
<maml:description>
4696+
<maml:para>Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file.</maml:para>
47314697
</maml:description>
47324698
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
47334699
</command:parameter>
@@ -4781,22 +4747,22 @@ Resources</dev:code>
47814747
</dev:defaultValue>
47824748
</command:parameter>
47834749
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4784-
<maml:name>TemplateParameterObject</maml:name>
4750+
<maml:name>TemplateUri</maml:name>
47854751
<maml:description>
4786-
<maml:para>Specifies a hash table of template parameter names and values. This parameter is optional. For help with hash tables in Windows PowerShell, type: Get-Help about_Hash_Tables.If a template has parameters, you must specify parameter values, but you can use this parameter or the TemplateParameterObject parameter. Also, the template parameters are added to the command dynamically when you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required parameter, the cmdlet prompts you for the value.</maml:para>
4752+
<maml:para>Specifies the URI of a JSON template file. This file can be a custom template or a gallery template that is saved as a JSON file.</maml:para>
47874753
</maml:description>
4788-
<command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue>
4754+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
47894755
<dev:type>
4790-
<maml:name>Hashtable</maml:name>
4756+
<maml:name>String</maml:name>
47914757
<maml:uri />
47924758
</dev:type>
47934759
<dev:defaultValue>
47944760
</dev:defaultValue>
47954761
</command:parameter>
47964762
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4797-
<maml:name>TemplateUri</maml:name>
4763+
<maml:name>TemplateFile</maml:name>
47984764
<maml:description>
4799-
<maml:para>Specifies the URI of a JSON template file. This file can be a custom template or a gallery template that is saved as a JSON file.</maml:para>
4765+
<maml:para>Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file.</maml:para>
48004766
</maml:description>
48014767
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
48024768
<dev:type>
@@ -4807,13 +4773,13 @@ Resources</dev:code>
48074773
</dev:defaultValue>
48084774
</command:parameter>
48094775
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4810-
<maml:name>TemplateFile</maml:name>
4776+
<maml:name>TemplateParameterObject</maml:name>
48114777
<maml:description>
4812-
<maml:para>Specifies the path and file name of a JSON template file on disk. This can be a custom template or a gallery template that is saved to disk as a JSON file.</maml:para>
4778+
<maml:para>Specifies a hash table of template parameter names and values. This parameter is optional. For help with hash tables in Windows PowerShell, type: Get-Help about_Hash_Tables.If a template has parameters, you must specify parameter values, but you can use this parameter or the TemplateParameterObject parameter. Also, the template parameters are added to the command dynamically when you specify a template. To use the dynamic parameters, just type them in the command, or type a minus sign to indicate a parameter name (-) and then press the TAB key repeatedly to cycle through the available parameters. If you miss a required parameter, the cmdlet prompts you for the value.</maml:para>
48134779
</maml:description>
4814-
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
4780+
<command:parameterValue required="true" variableLength="false">Hashtable</command:parameterValue>
48154781
<dev:type>
4816-
<maml:name>String</maml:name>
4782+
<maml:name>Hashtable</maml:name>
48174783
<maml:uri />
48184784
</dev:type>
48194785
<dev:defaultValue>
@@ -4832,6 +4798,19 @@ Resources</dev:code>
48324798
<dev:defaultValue>
48334799
</dev:defaultValue>
48344800
</command:parameter>
4801+
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
4802+
<maml:name>TemplateParameterUri</maml:name>
4803+
<maml:description>
4804+
<maml:para>Specifies the URI of a JSON template parameter file. This file includes all the parameters for the template.</maml:para>
4805+
</maml:description>
4806+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
4807+
<dev:type>
4808+
<maml:name>String</maml:name>
4809+
<maml:uri />
4810+
</dev:type>
4811+
<dev:defaultValue>
4812+
</dev:defaultValue>
4813+
</command:parameter>
48354814
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
48364815
<maml:name>Mode</maml:name>
48374816
<maml:description>

src/ResourceManager/Resources/Commands.Resources/Models.ResourceGroups/ResourceWithParameterBaseCmdlet.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ namespace Microsoft.Azure.Commands.Resources
3030
{
3131
public abstract class ResourceWithParameterBaseCmdlet : ResourcesBaseCmdlet
3232
{
33-
protected const string BaseParameterSetName = "Default";
3433
protected const string TemplateFileParameterObjectParameterSetName = "Deployment via template file and template parameters object";
3534
protected const string TemplateFileParameterFileParameterSetName = "Deployment via template file and template parameters file";
3635
protected const string TemplateFileParameterUriParameterSetName = "Deployment via template file template parameters uri";

0 commit comments

Comments
 (0)