Skip to content

[Compute] Add VmssId to New-AzVMConfig #9864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Compute/Compute.Test/Compute.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="28.2.0" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="28.3.0" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="2.4.2" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.14.0-preview" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ function Test-VirtualMachineProfile
# VM Profile & Hardware
$vmsize = 'Standard_A2';
$vmname = 'pstestvm' + ((Get-Random) % 10000);
$p = New-AzVMConfig -VMName $vmname -VMSize $vmsize;
$vmssID = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rggroup/providers/Microsoft.Compute/virtualMachineScaleSets/testvmss"
$p = New-AzVMConfig -VMName $vmname -VMSize $vmsize -VmssId $vmssID;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;
Assert-AreEqual $vmssID $p.VirtualMachineScaleSet.Id;

# Network
$ipname = 'hpfip' + ((Get-Random) % 10000);
Expand Down
1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Add VmssId to New-AzVMConfig cmdlet
* Add TerminateScheduledEvents and TerminateScheduledEventNotBeforeTimeoutInMinutes parameters to New-AzVmssConfig and Update-AzVmss
* Add HyperVGeneration property to VM image object
* Add Host and HostGroup features
Expand Down
2 changes: 1 addition & 1 deletion src/Compute/Compute/Compute.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<ItemGroup>
<PackageReference Include="AutoMapper" Version="6.2.2" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="28.2.0" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="28.3.0" />
<PackageReference Include="System.Security.Permissions" Version="4.5.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.4.1" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
Expand Down
3 changes: 3 additions & 0 deletions src/Compute/Compute/Models/PSVirtualMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,8 @@ public string ResourceGroupName

// Gets or sets the Host
public SubResource Host { get; set; }

// Gets or sets the VirtualMachineScaleSet
public SubResource VirtualMachineScaleSet { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ public class NewAzureVMConfigCommand : Microsoft.Azure.Commands.ResourceManager.
HelpMessage = "The Id of Host")]
public string HostId { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
HelpMessage = "The Id of virtual machine scale set")]
public string VmssId { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true)]
Expand Down Expand Up @@ -158,11 +163,16 @@ public override void ExecuteCmdlet()
vm.ProximityPlacementGroup = new SubResource(this.ProximityPlacementGroupId);
}

if (this.MyInvocation.BoundParameters.ContainsKey("HostId"))
if (this.IsParameterBound(c => c.HostId))
{
vm.Host = new SubResource(this.HostId);
}

if (this.IsParameterBound(c => c.VmssId))
{
vm.VirtualMachineScaleSet = new SubResource(this.VmssId);
}

WriteObject(vm);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,8 @@ public void DefaultExecuteCmdlet()
Identity = ComputeAutoMapperProfile.Mapper.Map<VirtualMachineIdentity>(this.VM.Identity),
Zones = this.Zone ?? this.VM.Zones,
ProximityPlacementGroup = this.VM.ProximityPlacementGroup,
Host = this.VM.Host
Host = this.VM.Host,
VirtualMachineScaleSet = this.VM.VirtualMachineScaleSet
};

Dictionary<string, List<string>> auxAuthHeader = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,17 @@ public override void ExecuteCmdlet()
NetworkProfile = this.VM.NetworkProfile,
OsProfile = this.VM.OSProfile,
Plan = this.VM.Plan,
LicenseType = this.VM.LicenseType,
AvailabilitySet = this.VM.AvailabilitySetReference,
Location = this.VM.Location,
LicenseType = this.VM.LicenseType,
Tags = this.Tag != null ? this.Tag.ToDictionary() : this.VM.Tags,
Identity = this.AssignIdentity.IsPresent
? new VirtualMachineIdentity(null, null, ResourceIdentityType.SystemAssigned, null)
: ComputeAutoMapperProfile.Mapper.Map<VirtualMachineIdentity>(this.VM.Identity),
Zones = (this.VM.Zones != null && this.VM.Zones.Count > 0) ? this.VM.Zones : null
Zones = (this.VM.Zones != null && this.VM.Zones.Count > 0) ? this.VM.Zones : null,
ProximityPlacementGroup = this.VM.ProximityPlacementGroup,
Host = this.VM.Host,
VirtualMachineScaleSet = this.VM.VirtualMachineScaleSet
};

if (this.IsParameterBound(c => c.IdentityType))
Expand Down
1 change: 0 additions & 1 deletion src/Compute/Compute/help/Get-AzHost.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ Id : /subscriptions/00000000-0000-0000-0000-000000000000/res
Name : crptestps2264host
Location : eastus
Tags : {"key1":"val2"}

```

This command returns the instance view of a host.
Expand Down
1 change: 0 additions & 1 deletion src/Compute/Compute/help/Get-AzHostGroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ ResourceGroupName Name Location Tags FDCount
----------------- ---- -------- ---- -------
myrg01 myhostgroup01 eastus {[key1, val1]} 1
myrg01 myhostgroup02 eastus {[key1, val1]} 2

```

This command returns all host groups in the given resource group.
Expand Down
26 changes: 21 additions & 5 deletions src/Compute/Compute/help/New-AzVMConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,24 @@ Creates a configurable virtual machine object.
### DefaultParameterSet (Default)
```
New-AzVMConfig [-VMName] <String> [-VMSize] <String> [[-AvailabilitySetId] <String>] [[-LicenseType] <String>]
[-Zone <String[]>] [-ProximityPlacementGroupId <String>] [-HostId <String>] [-Tags <Hashtable>]
[-EnableUltraSSD] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
[-Zone <String[]>] [-ProximityPlacementGroupId <String>] [-HostId <String>] [-VmssId <String>]
[-Tags <Hashtable>] [-EnableUltraSSD] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

### ExplicitIdentityParameterSet
```
New-AzVMConfig [-VMName] <String> [-VMSize] <String> [[-AvailabilitySetId] <String>] [[-LicenseType] <String>]
[-IdentityType] <ResourceIdentityType> [-IdentityId <String[]>] [-Zone <String[]>]
[-ProximityPlacementGroupId <String>] [-HostId <String>] [-Tags <Hashtable>] [-EnableUltraSSD]
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
[-ProximityPlacementGroupId <String>] [-HostId <String>] [-VmssId <String>] [-Tags <Hashtable>]
[-EnableUltraSSD] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

### AssignIdentityParameterSet
```
New-AzVMConfig [-VMName] <String> [-VMSize] <String> [[-AvailabilitySetId] <String>] [[-LicenseType] <String>]
[-AssignIdentity] [-Zone <String[]>] [-ProximityPlacementGroupId <String>] [-HostId <String>]
[-Tags <Hashtable>] [-EnableUltraSSD] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
[-VmssId <String>] [-Tags <Hashtable>] [-EnableUltraSSD] [-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -240,6 +241,21 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -VmssId
The Id of virtual machine scale set

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -Zone
Specifies the availability zone list for the virtual machine. The allowed values depend on the capabilities of the region. Allowed values will normally be 1,2,3.

Expand Down
2 changes: 1 addition & 1 deletion src/Network/Network.Test/Network.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.14.0-preview" />
<PackageReference Include="Microsoft.Azure.Insights" Version="0.16.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="28.2.0" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="28.3.0" />
<PackageReference Include="Microsoft.Azure.Management.ContainerInstance" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Redis" Version="4.4.1" />
<PackageReference Include="Microsoft.Azure.Management.OperationalInsights" Version="0.19.0-preview" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="28.2.0" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="28.3.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.14.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices" Version="4.2.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="3.1.1-preview" />
Expand Down