/// <summary> /// Initializes client properties. /// </summary> private void Initialize() { Operations = new Operations(this); AvailabilitySets = new AvailabilitySetsOperations(this); ProximityPlacementGroups = new ProximityPlacementGroupsOperations(this); VirtualMachineExtensionImages = new VirtualMachineExtensionImagesOperations(this); VirtualMachineExtensions = new VirtualMachineExtensionsOperations(this); VirtualMachineImages = new VirtualMachineImagesOperations(this); Usage = new UsageOperations(this); VirtualMachines = new VirtualMachinesOperations(this); VirtualMachineSizes = new VirtualMachineSizesOperations(this); Images = new ImagesOperations(this); VirtualMachineScaleSets = new VirtualMachineScaleSetsOperations(this); VirtualMachineScaleSetExtensions = new VirtualMachineScaleSetExtensionsOperations(this); VirtualMachineScaleSetRollingUpgrades = new VirtualMachineScaleSetRollingUpgradesOperations(this); VirtualMachineScaleSetVMs = new VirtualMachineScaleSetVMsOperations(this); LogAnalytics = new LogAnalyticsOperations(this); VirtualMachineRunCommands = new VirtualMachineRunCommandsOperations(this); ResourceSkus = new ResourceSkusOperations(this); Disks = new DisksOperations(this); Snapshots = new SnapshotsOperations(this); Galleries = new GalleriesOperations(this); GalleryImages = new GalleryImagesOperations(this); GalleryImageVersions = new GalleryImageVersionsOperations(this); ContainerServices = new ContainerServicesOperations(this); BaseUri = new System.Uri("https://management.azure.com"); AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; SerializationSettings = new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; SerializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings = new JsonSerializerSettings { DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; CustomInitialize(); DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); }
/// <summary> /// Initializes client properties. /// </summary> private void Initialize() { AvailabilitySets = new AvailabilitySetsOperations(this); VirtualMachineExtensionImages = new VirtualMachineExtensionImagesOperations(this); VirtualMachineExtensions = new VirtualMachineExtensionsOperations(this); VirtualMachineImages = new VirtualMachineImagesOperations(this); Usage = new UsageOperations(this); VirtualMachineSizes = new VirtualMachineSizesOperations(this); Images = new ImagesOperations(this); VirtualMachines = new VirtualMachinesOperations(this); VirtualMachineScaleSets = new VirtualMachineScaleSetsOperations(this); VirtualMachineScaleSetVMs = new VirtualMachineScaleSetVMsOperations(this); Disks = new DisksOperations(this); Snapshots = new SnapshotsOperations(this); BaseUri = new System.Uri("https://management.azure.com"); ApiVersion = "2016-04-30-preview"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; SerializationSettings = new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; SerializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings = new JsonSerializerSettings { DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; CustomInitialize(); DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); }
/// <summary> /// Initializes client properties. /// </summary> private void Initialize() { Images = new ImagesOperations(this); LabPlans = new LabPlansOperations(this); Operations = new Operations(this); Labs = new LabsOperations(this); OperationResults = new OperationResultsOperations(this); Schedules = new SchedulesOperations(this); Users = new UsersOperations(this); VirtualMachines = new VirtualMachinesOperations(this); Usages = new UsagesOperations(this); Skus = new SkusOperations(this); BaseUri = new System.Uri("https://management.azure.com"); ApiVersion = "2021-11-15-preview"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; SerializationSettings = new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; SerializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings = new JsonSerializerSettings { DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; CustomInitialize(); DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); }
private async Task <VirtualMachine> CreateCRPImage(string rgName, string imageName) { string storageAccountName = Recording.GenerateAssetName("saforgallery"); string asName = Recording.GenerateAssetName("asforgallery"); ImageReference imageRef = await GetPlatformVMImage(useWindowsImage : true); StorageAccount storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName); // resource group is also created in this method. VirtualMachine inputVM = null; var returnTwoVM = await CreateVM(rgName, asName, storageAccountOutput, imageRef); VirtualMachine createdVM = returnTwoVM.Item1; inputVM = returnTwoVM.Item2; Image imageInput = new Image(m_location) { Tags = { { "RG", "rg" }, { "testTag", "1" }, }, StorageProfile = new ImageStorageProfile() { OsDisk = new ImageOSDisk(OperatingSystemTypes.Windows, OperatingSystemStateTypes.Generalized) { BlobUri = createdVM.StorageProfile.OsDisk.Vhd.Uri, }, ZoneResilient = true }, HyperVGeneration = HyperVGenerationTypes.V1 }; await WaitForCompletionAsync(await ImagesOperations.StartCreateOrUpdateAsync(rgName, imageName, imageInput)); Image getImage = await ImagesOperations.GetAsync(rgName, imageName); sourceImageId = getImage.Id; return(createdVM); }
public async Task GalleryImageVersion_CRUD_Tests() { EnsureClientsInitialized(LocationEastUs2); string rgName = Recording.GenerateAssetName(ResourceGroupPrefix); VirtualMachine vm = null; string imageName = Recording.GenerateAssetName("psTestSourceImage"); vm = await CreateCRPImage(rgName, imageName); Assert.False(string.IsNullOrEmpty(sourceImageId)); Trace.TraceInformation(string.Format("Created the source image id: {0}", sourceImageId)); string galleryName = Recording.GenerateAssetName(GalleryNamePrefix); Gallery gallery = GetTestInputGallery(); await WaitForCompletionAsync(await GalleriesOperations.StartCreateOrUpdateAsync(rgName, galleryName, gallery)); Trace.TraceInformation(string.Format("Created the gallery: {0} in resource group: {1}", galleryName, rgName)); string galleryImageName = Recording.GenerateAssetName(GalleryImageNamePrefix); GalleryImage inputGalleryImage = GetTestInputGalleryImage(); await WaitForCompletionAsync((await GalleryImagesOperations.StartCreateOrUpdateAsync(rgName, galleryName, galleryImageName, inputGalleryImage))); Trace.TraceInformation(string.Format("Created the gallery image: {0} in gallery: {1}", galleryImageName, galleryName)); string galleryImageVersionName = "1.0.0"; GalleryImageVersion inputImageVersion = GetTestInputGalleryImageVersion(sourceImageId); await WaitForCompletionAsync(await GalleryImageVersionsOperations.StartCreateOrUpdateAsync(rgName, galleryName, galleryImageName, galleryImageVersionName, inputImageVersion)); Trace.TraceInformation(string.Format("Created the gallery image version: {0} in gallery image: {1}", galleryImageVersionName, galleryImageName)); GalleryImageVersion imageVersionFromGet = await GalleryImageVersionsOperations.GetAsync(rgName, galleryName, galleryImageName, galleryImageVersionName); Assert.NotNull(imageVersionFromGet); ValidateGalleryImageVersion(inputImageVersion, imageVersionFromGet); imageVersionFromGet = await GalleryImageVersionsOperations.GetAsync(rgName, galleryName, galleryImageName, galleryImageVersionName, ReplicationStatusTypes.ReplicationStatus); Assert.AreEqual(StorageAccountType.StandardLRS, imageVersionFromGet.PublishingProfile.StorageAccountType); Assert.AreEqual(StorageAccountType.StandardLRS, imageVersionFromGet.PublishingProfile.TargetRegions.First().StorageAccountType); Assert.NotNull(imageVersionFromGet.ReplicationStatus); Assert.NotNull(imageVersionFromGet.ReplicationStatus.Summary); inputImageVersion.PublishingProfile.EndOfLifeDate = Recording.UtcNow.AddDays(100); await WaitForCompletionAsync(await GalleryImageVersionsOperations.StartCreateOrUpdateAsync(rgName, galleryName, galleryImageName, galleryImageVersionName, inputImageVersion)); Trace.TraceInformation(string.Format("Updated the gallery image version: {0} in gallery image: {1}", galleryImageVersionName, galleryImageName)); imageVersionFromGet = await GalleryImageVersionsOperations.GetAsync(rgName, galleryName, galleryImageName, galleryImageVersionName); Assert.NotNull(imageVersionFromGet); ValidateGalleryImageVersion(inputImageVersion, imageVersionFromGet); Trace.TraceInformation("Listing the gallery image versions"); List <GalleryImageVersion> listGalleryImageVersionsResult = await(GalleryImageVersionsOperations. ListByGalleryImageAsync(rgName, galleryName, galleryImageName)).ToEnumerableAsync(); Assert.IsTrue(listGalleryImageVersionsResult.Count() == 1); //Assert.Single(listGalleryImageVersionsResult); //Assert.Null(listGalleryImageVersionsResult.NextPageLink); await WaitForCompletionAsync(await GalleryImageVersionsOperations.StartDeleteAsync(rgName, galleryName, galleryImageName, galleryImageVersionName)); listGalleryImageVersionsResult = await(GalleryImageVersionsOperations. ListByGalleryImageAsync(rgName, galleryName, galleryImageName)).ToEnumerableAsync(); //Assert.Null(listGalleryImageVersionsResult.NextPageLink); Trace.TraceInformation(string.Format("Deleted the gallery image version: {0} in gallery image: {1}", galleryImageVersionName, galleryImageName)); this.WaitMinutes(5); await WaitForCompletionAsync(await ImagesOperations.StartDeleteAsync(rgName, imageName)); Trace.TraceInformation("Deleted the CRP image."); await WaitForCompletionAsync(await VirtualMachinesOperations.StartDeleteAsync(rgName, vm.Name)); Trace.TraceInformation("Deleted the virtual machine."); await WaitForCompletionAsync(await GalleryImagesOperations.StartDeleteAsync(rgName, galleryName, galleryImageName)); Trace.TraceInformation("Deleted the gallery image."); WaitSeconds(100); await WaitForCompletionAsync(await GalleriesOperations.StartDeleteAsync(rgName, galleryName)); WaitSeconds(100); Trace.TraceInformation("Deleted the gallery."); }
private async Task CreateImageTestHelper(string originalTestLocation, string diskEncryptionSetId) { // Create resource group var rgName = Recording.GenerateAssetName(TestPrefix); var imageName = Recording.GenerateAssetName("imageTest"); // Create a VM, so we can use its OS disk for creating the image string storageAccountName = Recording.GenerateAssetName(TestPrefix); string asName = Recording.GenerateAssetName("as"); ImageReference imageRef = await GetPlatformVMImage(useWindowsImage : true); // Create Storage Account var storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName); // Add data disk to the VM. Action <VirtualMachine> addDataDiskToVM = vm => { string containerName = Recording.GenerateAssetName("testimageoperations", TestPrefix); var vhdContainer = "https://" + storageAccountName + ".blob.core.windows.net/" + containerName; var vhduri = vhdContainer + string.Format("/{0}.vhd", Recording.GenerateAssetName("testimageoperations", TestPrefix)); vm.HardwareProfile.VmSize = VirtualMachineSizeTypes.StandardA4; foreach (int index in new int[] { 1, 2 }) { var diskName = "dataDisk" + index; var ddUri = vhdContainer + string.Format("/{0}{1}.vhd", diskName, Recording.GenerateAssetName("testimageoperations", TestPrefix)); var dd = new DataDisk(1 + index, DiskCreateOptionTypes.Empty) { Caching = CachingTypes.None, Image = null, DiskSizeGB = 10, Name = diskName, Vhd = new VirtualHardDisk { Uri = ddUri } }; vm.StorageProfile.DataDisks.Add(dd); } var testStatus = new InstanceViewStatus { Code = "test", Message = "test" }; var testStatusList = new List <InstanceViewStatus> { testStatus }; }; // Create the VM, whose OS disk will be used in creating the image var returnTwoVM = await CreateVM(rgName, asName, storageAccountOutput, imageRef, addDataDiskToVM); var createdVM = returnTwoVM.Item1; int expectedDiskLunWithDiskEncryptionSet = createdVM.StorageProfile.DataDisks[0].Lun; // Create the Image var imageInput = new Image(m_location) { Tags = { { "RG", "rg" }, { "testTag", "1" }, }, StorageProfile = new ImageStorageProfile() { OsDisk = new ImageOSDisk(OperatingSystemTypes.Windows, OperatingSystemStateTypes.Generalized) { BlobUri = createdVM.StorageProfile.OsDisk.Vhd.Uri, DiskEncryptionSet = diskEncryptionSetId == null ? null : new DiskEncryptionSetParameters() { Id = diskEncryptionSetId }, }, DataDisks = { new ImageDataDisk(expectedDiskLunWithDiskEncryptionSet) { BlobUri = createdVM.StorageProfile.DataDisks[0].Vhd.Uri, DiskEncryptionSet = diskEncryptionSetId == null ? null: new DiskEncryptionSetParameters() { Id = diskEncryptionSetId }, } } }, HyperVGeneration = HyperVGenerationTypes.V1 }; var image = await WaitForCompletionAsync(await ImagesOperations.StartCreateOrUpdateAsync(rgName, imageName, imageInput)); var getImage = (await ImagesOperations.GetAsync(rgName, imageName)).Value; ValidateImage(imageInput, getImage); if (diskEncryptionSetId != null) { Assert.True(getImage.StorageProfile.OsDisk.DiskEncryptionSet != null, "OsDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getImage.StorageProfile.OsDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "getImage.StorageProfile.OsDisk.DiskEncryptionSet is not matching with expected DiskEncryptionSet resource"); Assert.AreEqual(1, getImage.StorageProfile.DataDisks.Count); Assert.True(getImage.StorageProfile.DataDisks[0].DiskEncryptionSet != null, ".DataDisks.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getImage.StorageProfile.DataDisks[0].DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "DataDisks.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); } ImageUpdate updateParams = new ImageUpdate(); updateParams.Tags.InitializeFrom(getImage.Tags); string tagKey = "UpdateTag"; updateParams.Tags.Add(tagKey, "TagValue"); await WaitForCompletionAsync(await ImagesOperations.StartUpdateAsync(rgName, imageName, updateParams)); getImage = (await ImagesOperations.GetAsync(rgName, imageName)).Value; Assert.True(getImage.Tags.ContainsKey(tagKey)); var listResponse = await(ImagesOperations.ListByResourceGroupAsync(rgName)).ToEnumerableAsync(); Assert.IsTrue(listResponse.Count() == 1); await WaitForCompletionAsync(await ImagesOperations.StartDeleteAsync(rgName, image.Value.Name)); }
/// <summary> /// Initializes client properties. /// </summary> private void Initialize() { Operations = new Operations(this); AvailabilitySets = new AvailabilitySetsOperations(this); ProximityPlacementGroups = new ProximityPlacementGroupsOperations(this); DedicatedHostGroups = new DedicatedHostGroupsOperations(this); DedicatedHosts = new DedicatedHostsOperations(this); SshPublicKeys = new SshPublicKeysOperations(this); VirtualMachineExtensionImages = new VirtualMachineExtensionImagesOperations(this); VirtualMachineExtensions = new VirtualMachineExtensionsOperations(this); VirtualMachineImages = new VirtualMachineImagesOperations(this); VirtualMachineImagesEdgeZone = new VirtualMachineImagesEdgeZoneOperations(this); Usage = new UsageOperations(this); VirtualMachines = new VirtualMachinesOperations(this); VirtualMachineScaleSets = new VirtualMachineScaleSetsOperations(this); VirtualMachineSizes = new VirtualMachineSizesOperations(this); Images = new ImagesOperations(this); RestorePointCollections = new RestorePointCollectionsOperations(this); RestorePoints = new RestorePointsOperations(this); CapacityReservationGroups = new CapacityReservationGroupsOperations(this); CapacityReservations = new CapacityReservationsOperations(this); VirtualMachineScaleSetExtensions = new VirtualMachineScaleSetExtensionsOperations(this); VirtualMachineScaleSetRollingUpgrades = new VirtualMachineScaleSetRollingUpgradesOperations(this); VirtualMachineScaleSetVMExtensions = new VirtualMachineScaleSetVMExtensionsOperations(this); VirtualMachineScaleSetVMs = new VirtualMachineScaleSetVMsOperations(this); LogAnalytics = new LogAnalyticsOperations(this); VirtualMachineRunCommands = new VirtualMachineRunCommandsOperations(this); VirtualMachineScaleSetVMRunCommands = new VirtualMachineScaleSetVMRunCommandsOperations(this); ResourceSkus = new ResourceSkusOperations(this); Disks = new DisksOperations(this); Snapshots = new SnapshotsOperations(this); DiskEncryptionSets = new DiskEncryptionSetsOperations(this); DiskAccesses = new DiskAccessesOperations(this); DiskRestorePoint = new DiskRestorePointOperations(this); Galleries = new GalleriesOperations(this); GalleryImages = new GalleryImagesOperations(this); GalleryImageVersions = new GalleryImageVersionsOperations(this); GalleryApplications = new GalleryApplicationsOperations(this); GalleryApplicationVersions = new GalleryApplicationVersionsOperations(this); GallerySharingProfile = new GallerySharingProfileOperations(this); SharedGalleries = new SharedGalleriesOperations(this); SharedGalleryImages = new SharedGalleryImagesOperations(this); SharedGalleryImageVersions = new SharedGalleryImageVersionsOperations(this); CommunityGalleries = new CommunityGalleriesOperations(this); CommunityGalleryImages = new CommunityGalleryImagesOperations(this); CommunityGalleryImageVersions = new CommunityGalleryImageVersionsOperations(this); CloudServiceRoleInstances = new CloudServiceRoleInstancesOperations(this); CloudServiceRoles = new CloudServiceRolesOperations(this); CloudServices = new CloudServicesOperations(this); CloudServicesUpdateDomain = new CloudServicesUpdateDomainOperations(this); CloudServiceOperatingSystems = new CloudServiceOperatingSystemsOperations(this); DiagnosticOperations = new DiagnosticOperations(this); DiskInspection = new DiskInspectionOperations(this); Diagnostics = new DiagnosticsOperations(this); DiskInspectionStorageConfiguration = new DiskInspectionStorageConfigurationOperations(this); BaseUri = new System.Uri("https://management.azure.com"); AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; SerializationSettings = new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; SerializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings = new JsonSerializerSettings { DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; CustomInitialize(); DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); }