internal RunCommandDocumentBase(string id, string schema, OperatingSystemTypes osType, string label, string description) : base(id) { Schema = schema; OsType = osType; Label = label; Description = description; }
internal ImageAnnotation( [JsonProperty("os")] OperatingSystemTypes osType, [JsonProperty("licenseType")] LicenseTypes licenseType) { this.LicenseType = licenseType; this.OperatingSystem = osType; }
public void AddLicenseAnnotation( ImageLocator image, OperatingSystemTypes osType, LicenseTypes licenseType) { this.LicenseAnnotations[image.ToString()] = new ImageAnnotation(osType, licenseType); }
/// <summary> /// Initializes a new instance of the RunCommandDocumentInner class. /// </summary> /// <param name="schema">The VM run command schema.</param> /// <param name="id">The VM run command id.</param> /// <param name="osType">The Operating System type. Possible values /// include: 'Windows', 'Linux'</param> /// <param name="label">The VM run command label.</param> /// <param name="description">The VM run command description.</param> /// <param name="script">The script to be executed.</param> /// <param name="parameters">The parameters used by the script.</param> public RunCommandDocumentInner(string schema, string id, OperatingSystemTypes osType, string label, string description, IList <string> script, IList <RunCommandParameterDefinition> parameters = default(IList <RunCommandParameterDefinition>)) : base(schema, id, osType, label, description) { Script = script; Parameters = parameters; CustomInit(); }
public virtual IEnumerable <InstanceHistory> GetInstances( OperatingSystemTypes osTypes, LicenseTypes licenseTypes) { return(this.History.Instances .Where(i => IsInstanceAnnotatedAs(i, osTypes, licenseTypes))); }
public static ResourceConfig <VirtualMachine> CreateVirtualMachineConfig( this ResourceConfig <ResourceGroup> resourceGroup, string name, ResourceConfig <NetworkInterface> networkInterface, OperatingSystemTypes osType, ResourceConfig <Disk> disk, string size, ResourceConfig <AvailabilitySet> availabilitySet, VirtualMachineIdentity identity, IEnumerable <int> dataDisks, IList <string> zones, bool ultraSSDEnabled, Func <IEngine, SubResource> proximityPlacementGroup, string hostId, string priority, string evictionPolicy, double?maxPrice, bool?encryptionAtHostEnabled ) => Strategy.CreateResourceConfig( resourceGroup: resourceGroup, name: name, createModel: engine => new VirtualMachine { NetworkProfile = new NetworkProfile { NetworkInterfaces = new[] { engine.GetReference(networkInterface) } }, HardwareProfile = new HardwareProfile { VmSize = size }, StorageProfile = new StorageProfile { OsDisk = new OSDisk { Name = disk.Name, CreateOption = DiskCreateOptionTypes.Attach, OsType = osType, ManagedDisk = engine.GetReference(disk, ultraSSDEnabled ? StorageAccountTypes.UltraSSDLRS : StorageAccountTypes.PremiumLRS), }, DataDisks = DataDiskStrategy.CreateDataDisks(null, dataDisks) }, Identity = identity, AvailabilitySet = engine.GetReference(availabilitySet), Zones = zones, AdditionalCapabilities = ultraSSDEnabled ? new AdditionalCapabilities(true) : null, ProximityPlacementGroup = proximityPlacementGroup(engine), Host = string.IsNullOrEmpty(hostId) ? null : new SubResource(hostId), Priority = priority, EvictionPolicy = evictionPolicy, BillingProfile = (maxPrice == null) ? null : new BillingProfile(maxPrice), SecurityProfile = new SecurityProfile { EncryptionAtHost = encryptionAtHostEnabled } });
internal RunCommandDocument(string schema, string id, OperatingSystemTypes osType, string label, string description, IEnumerable <string> script) : base(schema, id, osType, label, description) { if (schema == null) { throw new ArgumentNullException(nameof(schema)); } if (id == null) { throw new ArgumentNullException(nameof(id)); } if (label == null) { throw new ArgumentNullException(nameof(label)); } if (description == null) { throw new ArgumentNullException(nameof(description)); } if (script == null) { throw new ArgumentNullException(nameof(script)); } Script = script.ToArray(); }
internal static RunCommandDocument DeserializeRunCommandDocument(JsonElement element) { IReadOnlyList <string> script = default; Optional <IReadOnlyList <RunCommandParameterDefinition> > parameters = default; string schema = default; string id = default; OperatingSystemTypes osType = default; string label = default; string description = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("script")) { List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(item.GetString()); } script = array; continue; } if (property.NameEquals("parameters")) { List <RunCommandParameterDefinition> array = new List <RunCommandParameterDefinition>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(RunCommandParameterDefinition.DeserializeRunCommandParameterDefinition(item)); } parameters = array; continue; } if (property.NameEquals("$schema")) { schema = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("osType")) { osType = property.Value.GetString().ToOperatingSystemTypes(); continue; } if (property.NameEquals("label")) { label = property.Value.GetString(); continue; } if (property.NameEquals("description")) { description = property.Value.GetString(); continue; } } return(new RunCommandDocument(schema, id, osType, label, description, script, Optional.ToList(parameters))); }
/// <summary> /// Initializes a new instance of the ImageOSDisk class. /// </summary> /// <param name="osType">This property allows you to specify the type /// of the OS that is included in the disk if creating a VM from a /// custom image. <br><br> Possible values are: /// <br><br> **Windows** <br><br> **Linux**. /// Possible values include: 'Windows', 'Linux'</param> /// <param name="osState">The OS State. Possible values include: /// 'Generalized', 'Specialized'</param> /// <param name="snapshot">The snapshot.</param> /// <param name="managedDisk">The managedDisk.</param> /// <param name="blobUri">The Virtual Hard Disk.</param> /// <param name="caching">Specifies the caching requirements. /// <br><br> Possible values are: <br><br> /// **None** <br><br> **ReadOnly** <br><br> /// **ReadWrite** <br><br> Default: **None for Standard /// storage. ReadOnly for Premium storage**. Possible values include: /// 'None', 'ReadOnly', 'ReadWrite'</param> /// <param name="diskSizeGB">Specifies the size of empty data disks in /// gigabytes. This element can be used to overwrite the name of the /// disk in a virtual machine image. <br><br> This value /// cannot be larger than 1023 GB</param> /// <param name="storageAccountType">Specifies the storage account type /// for the managed disk. NOTE: UltraSSD_LRS can only be used with data /// disks, it cannot be used with OS Disk. Possible values include: /// 'Standard_LRS', 'Premium_LRS', 'StandardSSD_LRS', /// 'UltraSSD_LRS'</param> /// <param name="diskEncryptionSet">Specifies the customer managed disk /// encryption set resource id for the managed image disk.</param> public ImageOSDisk(OperatingSystemTypes osType, OperatingSystemStateTypes osState, Management.ResourceManager.Fluent.SubResource snapshot = default(Management.ResourceManager.Fluent.SubResource), Management.ResourceManager.Fluent.SubResource managedDisk = default(Management.ResourceManager.Fluent.SubResource), string blobUri = default(string), CachingTypes?caching = default(CachingTypes?), int?diskSizeGB = default(int?), StorageAccountTypes storageAccountType = default(StorageAccountTypes), Management.ResourceManager.Fluent.SubResource diskEncryptionSet = default(Management.ResourceManager.Fluent.SubResource)) : base(snapshot, managedDisk, blobUri, caching, diskSizeGB, storageAccountType, diskEncryptionSet) { OsType = osType; OsState = osState; CustomInit(); }
internal RunCommandDocument(string schema, string id, OperatingSystemTypes oSType, string label, string description, IEnumerable <string> script) : base(schema, id, oSType, label, description) { if (schema == null) { throw new ArgumentNullException(nameof(schema)); } if (id == null) { throw new ArgumentNullException(nameof(id)); } if (label == null) { throw new ArgumentNullException(nameof(label)); } if (description == null) { throw new ArgumentNullException(nameof(description)); } if (script == null) { throw new ArgumentNullException(nameof(script)); } Script = script.ToList(); Parameters = new ChangeTrackingList <RunCommandParameterDefinition>(); }
internal RunCommandDocumentBase(string schema, string id, OperatingSystemTypes osType, string label, string description) { if (schema == null) { throw new ArgumentNullException(nameof(schema)); } if (id == null) { throw new ArgumentNullException(nameof(id)); } if (label == null) { throw new ArgumentNullException(nameof(label)); } if (description == null) { throw new ArgumentNullException(nameof(description)); } Schema = schema; Id = id; OsType = osType; Label = label; Description = description; }
/// <summary> /// Checks whether the given type name is an encryption type name for given OS type. /// </summary> /// <param name="typeName">type name</param> /// <param name="osType">OS Type</param> /// <returns>true if the given type name is encryption type name</returns> internal static bool IsEncryptionTypeName(string typeName, OperatingSystemTypes osType) { if (typeName == null) { return(false); } return(typeName.Equals(GetTypeName(osType), System.StringComparison.OrdinalIgnoreCase)); }
/// <summary> /// Initializes a new instance of the RunCommandDocumentBase class. /// </summary> /// <param name="schema">The VM run command schema.</param> /// <param name="id">The VM run command id.</param> /// <param name="osType">The Operating System type. Possible values /// include: 'Windows', 'Linux'</param> /// <param name="label">The VM run command label.</param> /// <param name="description">The VM run command description.</param> public RunCommandDocumentBase(string schema, string id, OperatingSystemTypes osType, string label, string description) { Schema = schema; Id = id; OsType = osType; Label = label; Description = description; CustomInit(); }
public static GalleryImageData GetBasicGalleryImageData(Location location, OperatingSystemTypes osType, GalleryImageIdentifier identifier) { var data = new GalleryImageData(location) { OsType = osType, Identifier = identifier }; return(data); }
/// <summary> /// Initializes a new instance of the ImageOSDisk class. /// </summary> /// <param name="osType">This property allows you to specify the type /// of the OS that is included in the disk if creating a VM from a /// custom image. <br><br> Possible values are: /// <br><br> **Windows** <br><br> **Linux**. /// Possible values include: 'Windows', 'Linux'</param> /// <param name="osState">The OS State. Possible values include: /// 'Generalized', 'Specialized'</param> /// <param name="snapshot">The snapshot.</param> /// <param name="managedDisk">The managedDisk.</param> /// <param name="blobUri">The Virtual Hard Disk.</param> /// <param name="caching">Specifies the caching requirements. /// <br><br> Possible values are: <br><br> /// **None** <br><br> **ReadOnly** <br><br> /// **ReadWrite** <br><br> Default: **None for Standard /// storage. ReadOnly for Premium storage**. Possible values include: /// 'None', 'ReadOnly', 'ReadWrite'</param> /// <param name="diskSizeGB">Specifies the size of empty data disks in /// gigabytes. This element can be used to overwrite the name of the /// disk in a virtual machine image. <br><br> This value /// cannot be larger than 1023 GB</param> public ImageOSDisk(OperatingSystemTypes osType, OperatingSystemStateTypes osState, SubResource snapshot = default(SubResource), SubResource managedDisk = default(SubResource), string blobUri = default(string), CachingTypes?caching = default(CachingTypes?), int?diskSizeGB = default(int?)) { OsType = osType; OsState = osState; Snapshot = snapshot; ManagedDisk = managedDisk; BlobUri = blobUri; Caching = caching; DiskSizeGB = diskSizeGB; CustomInit(); }
/// <summary> /// Initializes a new instance of the GalleryApplicationUpdate class. /// </summary> /// <param name="supportedOSType">This property allows you to specify /// the supported type of the OS that application is built for. /// <br><br> Possible values are: <br><br> /// **Windows** <br><br> **Linux**. Possible values /// include: 'Windows', 'Linux'</param> /// <param name="tags">Resource tags</param> /// <param name="description">The description of this gallery /// Application Definition resource. This property is /// updatable.</param> /// <param name="eula">The Eula agreement for the gallery Application /// Definition.</param> /// <param name="privacyStatementUri">The privacy statement /// uri.</param> /// <param name="releaseNoteUri">The release note uri.</param> /// <param name="endOfLifeDate">The end of life date of the gallery /// Application Definition. This property can be used for /// decommissioning purposes. This property is updatable.</param> public GalleryApplicationUpdate(OperatingSystemTypes supportedOSType, string id = default(string), string name = default(string), string type = default(string), IDictionary <string, string> tags = default(IDictionary <string, string>), string description = default(string), string eula = default(string), string privacyStatementUri = default(string), string releaseNoteUri = default(string), System.DateTime?endOfLifeDate = default(System.DateTime?)) : base(id, name, type, tags) { Description = description; Eula = eula; PrivacyStatementUri = privacyStatementUri; ReleaseNoteUri = releaseNoteUri; EndOfLifeDate = endOfLifeDate; SupportedOSType = supportedOSType; CustomInit(); }
/// <summary> /// Given os type and no aad flag return the encryption extension version. /// </summary> /// <param name="osType">OS Type</param> /// <param name="isNoAAD">no aad flag</param> /// <returns>the encryption extension version</returns> internal static string GetVersion(OperatingSystemTypes osType, bool isNoAAD) { if (osType == OperatingSystemTypes.Linux) { return(isNoAAD ? LINUX_NOAAD_ENCRYPTION_EXTENSION_VERSION : LINUX_LEGACY_ENCRYPTION_EXTENSION_VERSION); } else { return(isNoAAD ? WINDOWS_NOAAD_ENCRYPTION_EXTENSION_VERSION : WINDOWS_LEGACY_ENCRYPTION_EXTENSION_VERSION); } }
/// <summary> /// Return OS specific encryption extension type. /// </summary> /// <param name="osType">OS Type</param> /// <returns>OS specific encryption extension type</returns> internal static string GetTypeName(OperatingSystemTypes osType) { if (osType == OperatingSystemTypes.Linux) { return(LINUX_ENCRYPTION_TYPE_NAME); } else { return(WINDOWS_ENCRYPTION_TYPE_NAME); } }
/// <summary> /// Initializes a new instance of the ImageOSDisk class. /// </summary> /// <param name="osType">This property allows you to specify the type /// of the OS that is included in the disk if creating a VM from a /// custom image. <br><br> Possible values are: /// <br><br> **Windows** <br><br> **Linux**. /// Possible values include: 'Windows', 'Linux'</param> /// <param name="osState">The OS State. Possible values include: /// 'Generalized', 'Specialized'</param> /// <param name="snapshot">The snapshot.</param> /// <param name="managedDisk">The managedDisk.</param> /// <param name="blobUri">The Virtual Hard Disk.</param> /// <param name="caching">Specifies the caching requirements. /// <br><br> Possible values are: <br><br> /// **None** <br><br> **ReadOnly** <br><br> /// **ReadWrite** <br><br> Default: **None for Standard /// storage. ReadOnly for Premium storage**. Possible values include: /// 'None', 'ReadOnly', 'ReadWrite'</param> /// <param name="diskSizeGB">Specifies the size of empty data disks in /// gigabytes. This element can be used to overwrite the name of the /// disk in a virtual machine image. <br><br> This value /// cannot be larger than 1023 GB</param> /// <param name="storageAccountType">Specifies the storage account type /// for the managed disk. Possible values are: Standard_LRS, /// Premium_LRS, and StandardSSD_LRS. Possible values include: /// 'Standard_LRS', 'Premium_LRS', 'StandardSSD_LRS'</param> public ImageOSDisk(OperatingSystemTypes osType, OperatingSystemStateTypes osState, Management.ResourceManager.Fluent.SubResource snapshot = default(Management.ResourceManager.Fluent.SubResource), Management.ResourceManager.Fluent.SubResource managedDisk = default(Management.ResourceManager.Fluent.SubResource), string blobUri = default(string), CachingTypes?caching = default(CachingTypes?), int?diskSizeGB = default(int?), StorageAccountTypes storageAccountType = default(StorageAccountTypes)) { OsType = osType; OsState = osState; Snapshot = snapshot; ManagedDisk = managedDisk; BlobUri = blobUri; Caching = caching; DiskSizeGB = diskSizeGB; StorageAccountType = storageAccountType; CustomInit(); }
internal static string ToSerializedValue(this OperatingSystemTypes value) { switch (value) { case OperatingSystemTypes.Windows: return("Windows"); case OperatingSystemTypes.Linux: return("Linux"); } return(null); }
internal static OSDiskImage DeserializeOSDiskImage(JsonElement element) { OperatingSystemTypes operatingSystem = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("operatingSystem")) { operatingSystem = property.Value.GetString().ToOperatingSystemTypes(); continue; } } return(new OSDiskImage(operatingSystem)); }
public static ResourceConfig <VirtualMachine> CreateVirtualMachineConfig( this ResourceConfig <ResourceGroup> resourceGroup, string name, ResourceConfig <NetworkInterface> networkInterface, OperatingSystemTypes osType, ResourceConfig <Disk> disk, string size, ResourceConfig <AvailabilitySet> availabilitySet) => Strategy.CreateResourceConfig( resourceGroup: resourceGroup, name: name, createModel: subscription => new VirtualMachine { OsProfile = null, NetworkProfile = new NetworkProfile { NetworkInterfaces = new[] { new NetworkInterfaceReference { Id = networkInterface.GetId(subscription).IdToString() } } }, HardwareProfile = new HardwareProfile { VmSize = size }, StorageProfile = new StorageProfile { OsDisk = new OSDisk { Name = disk.Name, CreateOption = DiskCreateOptionTypes.Attach, OsType = osType, ManagedDisk = new ManagedDiskParameters { StorageAccountType = StorageAccountTypes.PremiumLRS, Id = disk.GetId(subscription).IdToString() } } }, AvailabilitySet = availabilitySet == null ? null : new Azure.Management.Compute.Models.SubResource { Id = availabilitySet.GetId(subscription).IdToString() } }, dependencies: new IEntityConfig[] { networkInterface, disk, availabilitySet });
public ContainerGroupData(AzureLocation location, IEnumerable <ContainerInstanceContainer> containers, OperatingSystemTypes osType) : base(location) { if (containers == null) { throw new ArgumentNullException(nameof(containers)); } Containers = containers.ToList(); ImageRegistryCredentials = new ChangeTrackingList <ImageRegistryCredential>(); OSType = osType; Volumes = new ChangeTrackingList <ContainerInstanceVolume>(); SubnetIds = new ChangeTrackingList <ContainerGroupSubnetId>(); InitContainers = new ChangeTrackingList <InitContainerDefinitionContent>(); }
internal bool IsInstanceAnnotatedAs( InstanceHistory instance, OperatingSystemTypes osTypes, LicenseTypes licenseTypes) { if (instance.Image == null || !this.LicenseAnnotations.TryGetValue(instance.Image.ToString(), out ImageAnnotation annotation)) { annotation = ImageAnnotation.Default; } Debug.Assert(annotation != null); return(osTypes.HasFlag(annotation.OperatingSystem) && licenseTypes.HasFlag(annotation.LicenseType)); }
/// <summary> /// Switching between Linux and Windows OSes cause they have diffrent metric names /// </summary> /// <param name="ScaleSetId"></param> /// <param name="AzureInstance"></param> private void AutoSwitchOSMetrics(string ScaleSetId, IAzure AzureInstance) { var scaleset = AzureInstance.VirtualMachineScaleSets.GetById(ScaleSetId); //We should check OS type on instance level cause on ScaleSet level there is an issue with OSType param var list = scaleset.VirtualMachines.List(); if (list.Count() > 0) { if (list.FirstOrDefault().OSType == OperatingSystemTypes.Windows) { ClusterOSType = OperatingSystemTypes.Windows; CpuMetricName = CpuMetricNameWindows; DiskMetricName = DiskMetricNameWindows; } } }
/// <summary> /// Initializes a new instance of the GalleryImageInner class. /// </summary> /// <param name="osType">This property allows you to specify the type /// of the OS that is included in the disk when creating a VM from a /// managed image. <br><br> Possible values are: /// <br><br> **Windows** <br><br> **Linux**. /// Possible values include: 'Windows', 'Linux'</param> /// <param name="osState">The allowed values for OS State are /// 'Generalized'. Possible values include: 'Generalized', /// 'Specialized'</param> /// <param name="description">The description of this gallery Image /// Definition resource. This property is updatable.</param> /// <param name="eula">The Eula agreement for the gallery Image /// Definition.</param> /// <param name="privacyStatementUri">The privacy statement /// uri.</param> /// <param name="releaseNoteUri">The release note uri.</param> /// <param name="endOfLifeDate">The end of life date of the gallery /// Image Definition. This property can be used for decommissioning /// purposes. This property is updatable.</param> /// <param name="provisioningState">The current state of the gallery /// Image Definition.</param> public GalleryImageInner(string location, OperatingSystemTypes osType, OperatingSystemStateTypes osState, GalleryImageIdentifier identifier, string id = default(string), string name = default(string), string type = default(string), IDictionary <string, string> tags = default(IDictionary <string, string>), string description = default(string), string eula = default(string), string privacyStatementUri = default(string), string releaseNoteUri = default(string), System.DateTime?endOfLifeDate = default(System.DateTime?), RecommendedMachineConfiguration recommended = default(RecommendedMachineConfiguration), Disallowed disallowed = default(Disallowed), ImagePurchasePlan purchasePlan = default(ImagePurchasePlan), ProvisioningState provisioningState = default(ProvisioningState)) : base(location, id, name, type, tags) { Description = description; Eula = eula; PrivacyStatementUri = privacyStatementUri; ReleaseNoteUri = releaseNoteUri; OsType = osType; OsState = osState; EndOfLifeDate = endOfLifeDate; Identifier = identifier; Recommended = recommended; Disallowed = disallowed; PurchasePlan = purchasePlan; ProvisioningState = provisioningState; CustomInit(); }
/// <summary> /// Checks whether the given version is a legacy extension version or no-aad extension version /// for the given OS type. /// </summary> /// <param name="osType">OS Type</param> /// <param name="version">extension version</param> /// <returns>true if no-aad</returns> internal static bool IsNoAADVersion(OperatingSystemTypes osType, string version) { if (version == null) { return(false); } string majorVersion = version.Split('.')[0]; if (osType == OperatingSystemTypes.Linux) { return(majorVersion.Equals(LINUX_NOAAD_ENCRYPTION_EXTENSION_VERSION.Split('.')[0])); } else { return(majorVersion.Equals(WINDOWS_NOAAD_ENCRYPTION_EXTENSION_VERSION.Split('.')[0])); } }
internal ContainerGroupData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, IList <string> zones, ManagedServiceIdentity identity, string provisioningState, IList <ContainerInstanceContainer> containers, IList <ImageRegistryCredential> imageRegistryCredentials, ContainerGroupRestartPolicy?restartPolicy, IPAddress ipAddress, OperatingSystemTypes osType, IList <ContainerInstanceVolume> volumes, ContainerGroupPropertiesInstanceView instanceView, ContainerGroupDiagnostics diagnostics, IList <ContainerGroupSubnetId> subnetIds, DnsConfiguration dnsConfig, ContainerGroupSku?sku, Models.EncryptionProperties encryptionProperties, IList <InitContainerDefinitionContent> initContainers) : base(id, name, resourceType, systemData, tags, location, zones) { Identity = identity; ProvisioningState = provisioningState; Containers = containers; ImageRegistryCredentials = imageRegistryCredentials; RestartPolicy = restartPolicy; IPAddress = ipAddress; OSType = osType; Volumes = volumes; InstanceView = instanceView; Diagnostics = diagnostics; SubnetIds = subnetIds; DnsConfig = dnsConfig; Sku = sku; EncryptionProperties = encryptionProperties; InitContainers = initContainers; }
public static ResourceConfig <VirtualMachine> CreateVirtualMachineConfig( this ResourceConfig <ResourceGroup> resourceGroup, string name, ResourceConfig <NetworkInterface> networkInterface, OperatingSystemTypes osType, ResourceConfig <Disk> disk, string size, ResourceConfig <AvailabilitySet> availabilitySet, VirtualMachineIdentity identity, IEnumerable <int> dataDisks, IList <string> zones, bool ultraSSDEnabled) => Strategy.CreateResourceConfig( resourceGroup: resourceGroup, name: name, createModel: engine => new VirtualMachine { NetworkProfile = new NetworkProfile { NetworkInterfaces = new[] { engine.GetReference(networkInterface) } }, HardwareProfile = new HardwareProfile { VmSize = size }, StorageProfile = new StorageProfile { OsDisk = new OSDisk { Name = disk.Name, CreateOption = DiskCreateOptionTypes.Attach, OsType = osType, ManagedDisk = engine.GetReference(disk, ultraSSDEnabled ? StorageAccountTypes.UltraSSDLRS : StorageAccountTypes.PremiumLRS), }, DataDisks = DataDiskStrategy.CreateDataDisks(null, dataDisks) }, Identity = identity, AvailabilitySet = engine.GetReference(availabilitySet), Zones = zones, AdditionalCapabilities = ultraSSDEnabled ? new AdditionalCapabilities(true) : null });
/// <summary> /// Install or update the MSI extension in the virtual machine and creates a RBAC role assignment for the System Assigned Service Principal. /// </summary> /// <param name="virtualMachine">The virtual machine for which the MSI needs to be enabled.</param> /// <return>True if the extension is installed</return> internal async Task <Boolean> SetMSIExtensionIfRequiredAndHandleSystemAssignedMSIRoleAssignmentsAsync(IVirtualMachine virtualMachine, CancellationToken cancellationToken = default(CancellationToken)) { if (virtualMachine.Inner == null) { throw new ArgumentException("Method requires fluent model to be fully populated"); } try { bool isExtensionInstalledOrUpdated = false; // Install or Update the MSI extension // if (this.installExtensionIfNotInstalled) { OperatingSystemTypes osType = virtualMachine.OSType; string extensionTypeName = osType == OperatingSystemTypes.Linux ? "ManagedIdentityExtensionForLinux" : "ManagedIdentityExtensionForWindows"; var extension = await GetMSIExtensionAsync(virtualMachine, extensionTypeName); if (extension != null) { isExtensionInstalledOrUpdated = await UpdateMSIExtensionAsync(virtualMachine, extension, extensionTypeName, cancellationToken); } else { isExtensionInstalledOrUpdated = await InstallMSIExtensionAsync(virtualMachine, extensionTypeName); } } // Create, Delete System Assigned MSI Role assignments // if (IsSystemAssignedMSIEnabled(virtualMachine)) { await CommitsRoleAssignmentsPendingActionAsync(cancellationToken); } return(isExtensionInstalledOrUpdated); } finally { this.installExtensionIfNotInstalled = false; this.tokenPort = null; } }