Skip to content

Commit 381c639

Browse files
SandidomsJinLei
andauthored
Fix UserData metadata so piping occurs correctly (#16728)
* changed metadata * availaiblity zone test * Update AvailabilityZoneTests.ps1 * changelog * help docs * base64 validation edit * Update SignatureIssues.csv * Update SignatureIssues.csv * Update SignatureIssues.csv * Update BreakingChangeIssues.csv * Update ChangeLog.md Polish change log for Compute * Update BreakingChangeIssues.csv * Update SignatureIssues.csv * Update BreakingChangeIssues.csv Co-authored-by: Jin Lei <[email protected]>
1 parent fcb07cc commit 381c639

23 files changed

+57
-34
lines changed

src/Compute/Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
2121
-->
2222
## Upcoming Release
23+
* Updated `UserData` parameter in VM and VMSS cmdlets to pipe by the Property Name to ensure piping scenarios occur correctly.
2324
* Changed `New-AzVM` cmdlet when using the SimpleParameterSet to not create a `PublicIPAddress` when a `PublicIPAddress` name is not provided.
2425
* Added `PlatformFaultDomain` parameter to cmdlets: `New-AzVM` and `New-AzVMConfig`
2526
* Added `-Feature` parameter for `New-AzGalleryImageDefinition`

src/Compute/Compute/Common/ValidateBase64EncodedString.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ public static class ValidateBase64EncodedString
1515
public const string UserDataEncodeNotification = "The provided UserData parameter value was not Base64 encoded. The cmdlet has automatically changed your value by Base64 encoding it.";
1616
public static bool ValidateStringIsBase64Encoded(string encodedString)
1717
{
18-
if (encodedString.Contains(" ") ||
18+
if (!string.IsNullOrEmpty(encodedString) &&
19+
(encodedString.Contains(" ") ||
1920
encodedString.Length % 4 != 0 ||
2021
encodedString.Contains("\t") ||
2122
encodedString.Contains("\r") ||
22-
encodedString.Contains("\n"))
23+
encodedString.Contains("\n")))
2324
{
2425
return false;
2526
}

src/Compute/Compute/Generated/VirtualMachineScaleSet/Config/NewAzureRmVmssConfigCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public partial class NewAzureRmVmssConfigCommand : Microsoft.Azure.Commands.Reso
282282
[Parameter(
283283
Mandatory = false,
284284
HelpMessage = "UserData for the VM, which will be Base64 encoded. Customer should not pass any secrets in here.",
285-
ValueFromPipeline = true)]
285+
ValueFromPipelineByPropertyName = true)]
286286
public string UserData { get; set; }
287287

288288
protected override void ProcessRecord()

src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetCreateOrUpdateMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ private int convertAPIVersionToInt(string networkAPIVersion)
186186
Mandatory = false,
187187
ParameterSetName = SimpleParameterSet,
188188
HelpMessage = "UserData for the Vmss, which will be Base64 encoded. Customer should not pass any secrets in here.",
189-
ValueFromPipeline = true)]
189+
ValueFromPipelineByPropertyName = true)]
190190
public string UserData { get; set; }
191191
}
192192
}

src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetGetMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public override void ExecuteCmdlet()
171171
Mandatory = false,
172172
ParameterSetName = FriendMethod,
173173
HelpMessage = "UserData for the Vmss, which will be Base64 encoded. Customer should not pass any secrets in here.",
174-
ValueFromPipeline = true)]
174+
ValueFromPipelineByPropertyName = true)]
175175
public SwitchParameter UserData { get; set; }
176176
}
177177
}

src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetUpdateMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public override void ExecuteCmdlet()
345345
[Parameter(
346346
Mandatory = false,
347347
HelpMessage = "UserData for the Vmss, which will be Base64 encoded. Customer should not pass any secrets in here.",
348-
ValueFromPipeline = true)]
348+
ValueFromPipelineByPropertyName = true)]
349349
public string UserData { get; set; }
350350

351351
private void BuildPatchObject()

src/Compute/Compute/Generated/VirtualMachineScaleSetVM/VirtualMachineScaleSetVMGetMethod.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,12 @@ public override void ExecuteCmdlet()
166166
Mandatory = false,
167167
ParameterSetName = DefaultParameterSet,
168168
HelpMessage = "UserData for the Vmss, which will be Base64 encoded. Customer should not pass any secrets in here.",
169-
ValueFromPipeline = true)]
169+
ValueFromPipelineByPropertyName = true)]
170170
[Parameter(
171171
Mandatory = false,
172172
ParameterSetName = FriendMethodParameterSet,
173173
HelpMessage = "UserData for the Vmss, which will be Base64 encoded. Customer should not pass any secrets in here.",
174-
ValueFromPipeline = true)]
174+
ValueFromPipelineByPropertyName = true)]
175175
public SwitchParameter UserData { get; set; }
176176
}
177177
}

src/Compute/Compute/Generated/VirtualMachineScaleSetVM/VirtualMachineScaleSetVMUpdateMethod.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ public override void ExecuteCmdlet()
196196
Mandatory = false,
197197
ParameterSetName = "DefaultParameter",
198198
HelpMessage = "UserData for the Vmss Vm, which will be Base64 encoded. Customer should not pass any secrets in here.",
199-
ValueFromPipeline = true)]
199+
ValueFromPipelineByPropertyName = true)]
200200
[Parameter(
201201
Mandatory = false,
202202
ParameterSetName = "ResourceIdParameter",
203203
HelpMessage = "UserData for the Vmss Vm, which will be Base64 encoded. Customer should not pass any secrets in here.",
204-
ValueFromPipeline = true)]
204+
ValueFromPipelineByPropertyName = true)]
205205
public string UserData { get; set; }
206206
}
207207
}

src/Compute/Compute/VirtualMachine/Config/NewAzureVMConfigCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ protected override bool IsUsageMetricEnabled
141141
Mandatory = false,
142142
ParameterSetName = ExplicitIdentityParameterSet,
143143
HelpMessage = "UserData for the VM, which will be Base64 encoded. Customer should not pass any secrets in here.",
144-
ValueFromPipeline = true)]
144+
ValueFromPipelineByPropertyName = true)]
145145
[Parameter(
146146
Mandatory = false,
147147
ParameterSetName = DefaultParameterSetName,
148148
HelpMessage = "UserData for the VM, which will be Base64 encoded. Customer should not pass any secrets in here.",
149-
ValueFromPipeline = true)]
149+
ValueFromPipelineByPropertyName = true)]
150150
public string UserData { get; set; }
151151

152152
[Parameter(

src/Compute/Compute/VirtualMachine/Operation/GetAzureVMCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,22 @@ public class GetAzureVMCommand : VirtualMachineBaseCmdlet
103103
Mandatory = false,
104104
ParameterSetName = DefaultParamSet,
105105
HelpMessage = "UserData for the VM, which will be Base64 encoded. Customer should not pass any secrets in here.",
106-
ValueFromPipeline = true)]
106+
ValueFromPipelineByPropertyName = true)]
107107
[Parameter(
108108
Mandatory = false,
109109
ParameterSetName = GetVirtualMachineInResourceGroupParamSet,
110110
HelpMessage = "UserData for the VM, which will be Base64 encoded. Customer should not pass any secrets in here.",
111-
ValueFromPipeline = true)]
111+
ValueFromPipelineByPropertyName = true)]
112112
[Parameter(
113113
Mandatory = false,
114114
ParameterSetName = ListNextLinkVirtualMachinesParamSet,
115115
HelpMessage = "UserData for the VM, which will be Base64 encoded. Customer should not pass any secrets in here.",
116-
ValueFromPipeline = true)]
116+
ValueFromPipelineByPropertyName = true)]
117117
[Parameter(
118118
Mandatory = false,
119119
ParameterSetName = ListLocationVirtualMachinesParamSet,
120120
HelpMessage = "UserData for the VM, which will be Base64 encoded. Customer should not pass any secrets in here.",
121-
ValueFromPipeline = true)]
121+
ValueFromPipelineByPropertyName = true)]
122122
public SwitchParameter UserData { get; set; }
123123

124124
public override void ExecuteCmdlet()

0 commit comments

Comments
 (0)