/// <summary> /// Initialize a storage profile /// </summary> /// <param name="primaryDisk">Properties of the primary or OS disk</param> /// <param name="isZoneResilient">Flag indicating if the storage or disk image is zone-resilient</param> /// <param name="dataDisks">Collection of data disks in the image</param> public ImageStorageProfile(ImageOSDisk primaryDisk, bool isZoneResilient = false, IEnumerable <ImageDataDisk>?dataDisks = null) { IsZoneResilient = isZoneResilient; PrimaryDisk = primaryDisk ?? throw new ArgumentNullException(nameof(primaryDisk)); DataDisks = (((dataDisks == null) || (dataDisks.Count() == 0)) ? null : new List <ImageDataDisk>()); if (((dataDisks != null) && (dataDisks.Count() > 0)) && (DataDisks != null)) { DataDisks.AddRange(dataDisks); } }
/// <summary> /// Initialize a new set of properties /// </summary> /// <param name="generation">The HyperV generation of the VM created from the image</param> /// <param name="sourceVM">URI to the VM from which this image was created</param> /// <param name="primaryDisk">Properties of the primary or OS disk</param> /// <param name="isZoneResilient">Flag indicating if the storage or disk image is zone-resilient</param> /// <param name="dataDisks">Collection of data disks in the image</param> public DiskImageProperties(HyperVGenerationNamesEnum generation, ResourceUri sourceVM, ImageOSDisk primaryDisk, bool isZoneResilient = false, IEnumerable <ImageDataDisk>?dataDisks = null) { if (!Enum.IsDefined(typeof(HyperVGenerationNamesEnum), generation)) { throw new ArgumentOutOfRangeException(nameof(generation)); } if ((sourceVM == null) || (!sourceVM.IsValid)) { throw new ArgumentException(nameof(sourceVM)); } HyperVGeneration = generation; SourceVirtualMachine = new SubResource(sourceVM); StorageProfile = new ImageStorageProfile(primaryDisk, isZoneResilient, dataDisks); }
/// <summary> /// Set primary disk (for an managed disk) /// </summary> /// <param name="osName">Type of OS on the disk</param> /// <param name="isGeneralized">If true, image is generalied, suitable to create a new VM</param> /// <param name="storageType">Type of storage account stored on (cannot be UltraSSD_LRS)</param> /// <param name="caching">Type of caching used on the disk</param> /// <param name="sizeInGB">Size in GB (must be from 1 to 1023)</param> /// <param name="diskUri">Uri to the managed disk</param> public void SetPrimaryDisk(OSTypeNamesEnum osName, bool isGeneralized, DiskSkuNamesEnum storageType, CachingTypeNamesEnum caching, int sizeInGB, ResourceUri diskUri) => PrimaryDisk = new ImageOSDisk(osName, isGeneralized, storageType, caching, sizeInGB, diskUri);