Exemplo n.º 1
0
        private bool WaitForPIRDisappear(string imageName, int waitTimeInMin = 1, int maxWaitTimeInMin = 30)
        {
            DateTime startTime = DateTime.Now;

            while (true)
            {
                try
                {
                    OSImageContext imageContext = vmPowershellCmdlets.GetAzureVMImage(imageName)[0];

                    if ((DateTime.Now - startTime).TotalMinutes < maxWaitTimeInMin)
                    {
                        Thread.Sleep(waitTimeInMin * 1000 * 60);
                    }
                    else
                    {
                        Assert.Fail("Still has image, {0}, after {1} minutes!", imageName, maxWaitTimeInMin);
                    }
                }
                catch (Exception e)
                {
                    if (e.ToString().Contains("ResourceNotFound"))
                    {
                        Console.WriteLine("Image {0} disappered after {1} minutes.", imageName, (DateTime.Now - startTime).TotalMinutes);
                        return(true);
                    }
                    else
                    {
                        Console.WriteLine(e.ToString());
                        throw;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void AzureVMImageSizeTest()
        {
            vhdName = "os2.vhd";
            string newImageName  = Utilities.GetUniqueShortName("vmimage");
            string mediaLocation = string.Format("{0}{1}/{2}", blobUrlRoot, vhdContainerName, vhdName);

            try
            {
                var instanceSizes = vmPowershellCmdlets.GetAzureRoleSize().ToArray();
                int arrayLength   = instanceSizes.Count();

                for (int i = 0; i < arrayLength; i++)
                {
                    Utilities.PrintContext(instanceSizes[i]);
                    // Add-AzureVMImage test for VM size
                    OSImageContext result         = vmPowershellCmdlets.AddAzureVMImage(newImageName, mediaLocation, OS.Windows, null, instanceSizes[i].InstanceSize);
                    OSImageContext resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                    Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                    // Update-AzureVMImage test for VM size
                    result         = vmPowershellCmdlets.UpdateAzureVMImage(newImageName, null, instanceSizes[Math.Max((i + 1) % arrayLength, 1)].InstanceSize);
                    resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                    Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                    vmPowershellCmdlets.RemoveAzureVMImage(newImageName);
                }
            }
            catch (Exception e)
            {
                pass = false;
                Console.WriteLine("Exception occurred: {0}", e.ToString());
                throw;
            }
        }
Exemplo n.º 3
0
        public void AzureVMImageSizeTest()
        {
            string newImageName  = Utilities.GetUniqueShortName("vmimage");
            string mediaLocation = string.Format("{0}{1}/{2}", blobUrlRoot, vhdContainerName, vhdName);

            try
            {
                Array instanceSizes = Enum.GetValues(typeof(InstanceSize));
                int   arrayLength   = instanceSizes.GetLength(0);

                for (int i = 1; i < arrayLength; i++)
                {
                    // Add-AzureVMImage test for VM size
                    OSImageContext result         = vmPowershellCmdlets.AddAzureVMImage(newImageName, mediaLocation, OS.Windows, (InstanceSize)instanceSizes.GetValue(i));
                    OSImageContext resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                    Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                    // Update-AzureVMImage test for VM size
                    result         = vmPowershellCmdlets.UpdateAzureVMImage(newImageName, (InstanceSize)instanceSizes.GetValue(Math.Max((i + 1) % arrayLength, 1)));
                    resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                    Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                    vmPowershellCmdlets.RemoveAzureVMImage(newImageName);
                }
            }
            catch (Exception e)
            {
                pass = false;
                Console.WriteLine("Exception occurred: {0}", e.ToString());
                throw;
            }
        }
Exemplo n.º 4
0
        public void AzurePlatformVMImageScenarioTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            string vmName  = Utilities.GetUniqueShortName("pirtestvm");
            string svcName = Utilities.GetUniqueShortName("pirtestservice");

            try
            {
                SwitchToNormalUser();

                try
                {
                    vmPowershellCmdlets.GetAzureStorageAccount(storageNormalUser);
                }
                catch (Exception e)
                {
                    if (e.ToString().Contains("ResourceNotFound"))
                    {
                        vmPowershellCmdlets.NewAzureStorageAccount(storageNormalUser, location1);
                    }
                    else
                    {
                        Console.WriteLine(e.ToString());
                        throw;
                    }
                }
                vmPowershellCmdlets.SetAzureSubscription(normaluser, normaluserSubId, storageNormalUser);

                // Replicate the user image to "West US" and wait until the replication process is completed.
                SwitchToPublisher();
                vmPowershellCmdlets.SetAzurePlatformVMImageReplicate(image, new string[] { location1 });

                // Make the replicated image public and wait until the PIR image shows up.
                vmPowershellCmdlets.SetAzurePlatformVMImagePublic(image);
                OSImageContext pirImage = WaitForPIRAppear(image, publisher);

                // Switch to the normal User and check the PIR image.
                SwitchToNormalUser();
                WaitForPIRAppear(image, publisher);

                // Create a VM using the PIR image
                vmPowershellCmdlets.NewAzureQuickVM(OS.Windows, vmName, svcName, pirImage.ImageName, username, password, location1);
                Console.WriteLine("VM, {0}, is successfully created using the uploaded PIR image", vmPowershellCmdlets.GetAzureVM(vmName, svcName).Name);

                // Remove the service and VM
                vmPowershellCmdlets.RemoveAzureService(svcName);

                // Switch to the publisher and remove the PIR image
                SwitchToPublisher();
                vmPowershellCmdlets.RemoveAzurePlatformVMImage(image);

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
        }
Exemplo n.º 5
0
 protected override void ProcessRecord()
 {
     try
     {
         base.ProcessRecord();
         string  empty   = string.Empty;
         OSImage oSImage = this.UpdateVMImageProcess(out empty);
         if (oSImage != null)
         {
             OSImageContext oSImageContext = new OSImageContext();
             oSImageContext.set_OperationId(empty);
             oSImageContext.AffinityGroup = oSImage.AffinityGroup;
             oSImageContext.Category      = oSImage.Category;
             oSImageContext.Label         = oSImage.Label;
             oSImageContext.Location      = oSImage.Location;
             oSImageContext.MediaLink     = oSImage.MediaLink;
             oSImageContext.ImageName     = oSImage.Name;
             oSImageContext.OS            = oSImage.OS;
             OSImageContext oSImageContext1 = oSImageContext;
             base.WriteObject(oSImageContext1, true);
         }
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         base.WriteError(new ErrorRecord(exception, string.Empty, ErrorCategory.CloseError, null));
     }
 }
Exemplo n.º 6
0
        public void AzurePlatformVMImageMultipleLocationsTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            try
            {
                // starting the test.
                PrintOSImageDetailsContext(vmPowershellCmdlets.GetAzurePlatformVMImage(image));

                // Replicate the user image to "West US" and wait until the replication process is completed.
                ComputeImageConfig compCfg = new ComputeImageConfig
                {
                    Offer   = "test",
                    Sku     = "test",
                    Version = "test"
                };
                MarketplaceImageConfig marketCfg = null;
                vmPowershellCmdlets.SetAzurePlatformVMImageReplicate(image, new string[] { location1, location2 }, compCfg, marketCfg);
                PrintOSImageDetailsContext(vmPowershellCmdlets.GetAzurePlatformVMImage(image));
                WaitForReplicationComplete(image);

                // Make the replicated image public and wait until the PIR image shows up.
                vmPowershellCmdlets.SetAzurePlatformVMImagePublic(image);
                OSImageContext pirImage = WaitForPIRAppear(image, publisher);
                PrintOSImageDetailsContext(vmPowershellCmdlets.GetAzurePlatformVMImage(image));

                // Check the locations of the PIR image.
                string pirlocations = vmPowershellCmdlets.GetAzureVMImage(pirImage.ImageName)[0].Location;
                Assert.IsTrue(pirlocations.Contains(location1));
                Assert.IsTrue(pirlocations.Contains(location2));
                Assert.IsFalse(pirlocations.Contains(location3));

                // Switch to the normal User and check the PIR image.
                SwitchToNormalUser();
                Assert.IsTrue(Utilities.CheckRemove(vmPowershellCmdlets.GetAzureVMImage, image));
                WaitForPIRAppear(image, publisher);

                // Switch to the publisher and make the PIR image private
                SwitchToPublisher();
                vmPowershellCmdlets.SetAzurePlatformVMImagePrivate(image);

                // Switch to the normal User and wait until the PIR image disapper
                SwitchToNormalUser();
                WaitForPIRDisappear(pirImage.ImageName);

                // Switch to the publisher and remove the PIR image.
                SwitchToPublisher();
                vmPowershellCmdlets.RemoveAzurePlatformVMImage(image);
                Assert.AreEqual(0, vmPowershellCmdlets.GetAzurePlatformVMImage(image).ReplicationProgress.Count);
                PrintOSImageDetailsContext(vmPowershellCmdlets.GetAzurePlatformVMImage(image));

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
        }
Exemplo n.º 7
0
        public void VerifyOsImage(string ImageName, OSImageContext imageContext)
        {
            var vmImage = vmPowershellCmdlets.GetAzureVMImage(ImageName);

            Utilities.PrintContext(vmImage[0]);
            Assert.AreEqual(imageContext.ImageName, vmImage[0].ImageName, "ImageName property of the saved os image is not matching.");
            Assert.AreEqual(imageContext.Category, vmImage[0].Category, "Category property of the saved os image is not matching.");
            Assert.AreEqual(imageContext.Location, vmImage[0].Location, "Location property of the saved os image is not matching.");
            Assert.AreEqual(imageContext.Label, vmImage[0].Label, "Label property of the saved os image is not matching.");
            Assert.AreEqual(imageContext.OS, vmImage[0].OS, "OS property of the saved os image is not matching.");
        }
Exemplo n.º 8
0
        public void AzureVMImageTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
            vhdName = "os1.vhd";
            string newImageName  = Utilities.GetUniqueShortName("vmimage");
            string mediaLocation = string.Format("{0}{1}/{2}", blobUrlRoot, vhdContainerName, vhdName);

            string oldLabel     = "old label";
            string newLabel     = "new label";
            string vmSize       = "Small";
            var    iconUri      = "http://www.bing.com";
            var    smallIconUri = "http://www.bing.com";
            bool   showInGui    = true;

            try
            {
                OSImageContext result = vmPowershellCmdlets.AddAzureVMImage(newImageName, mediaLocation, OS.Windows, oldLabel, vmSize, iconUri, smallIconUri, showInGui);

                OSImageContext resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                Assert.IsTrue(!string.IsNullOrEmpty(resultReturned.IOType));
                Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                result         = vmPowershellCmdlets.UpdateAzureVMImage(newImageName, newLabel);
                resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                Assert.IsTrue(!string.IsNullOrEmpty(resultReturned.IOType));
                Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                result         = vmPowershellCmdlets.UpdateAzureVMImage(newImageName, newLabel, true);
                resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                Assert.IsTrue(resultReturned.ShowInGui.HasValue && !resultReturned.ShowInGui.Value);
                Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                vmPowershellCmdlets.RemoveAzureVMImage(newImageName, false);
                Assert.IsTrue(Utilities.CheckRemove(vmPowershellCmdlets.GetAzureVMImage, newImageName));

                pass = true;
            }
            catch (Exception e)
            {
                pass = false;
                Assert.Fail("Exception occurred: {0}", e.ToString());
            }
            finally
            {
                if (!Utilities.CheckRemove(vmPowershellCmdlets.GetAzureVMImage, newImageName))
                {
                    vmPowershellCmdlets.RemoveAzureVMImage(newImageName, false);
                }
            }
        }
Exemplo n.º 9
0
        public void AddVMImageProcess()
        {
            AddAzureVMImageCommand.AddAzureVMImageCommand variable = null;
            string imageName;

            using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
            {
                try
                {
                    AddAzureVMImageCommand.AddAzureVMImageCommand variable1 = variable;
                    OSImage oSImage = new OSImage();
                    oSImage.Name      = this.ImageName;
                    oSImage.MediaLink = new Uri(this.MediaLocation);
                    OSImage oSImage1 = oSImage;
                    if (string.IsNullOrEmpty(this.Label))
                    {
                        imageName = this.ImageName;
                    }
                    else
                    {
                        imageName = this.Label;
                    }
                    oSImage1.Label  = imageName;
                    oSImage.OS      = this.OS;
                    variable1.image = oSImage;
                    CmdletExtensions.WriteVerboseOutputForObject(this, LambdaVar23);
                    OSImage        oSImage2       = base.RetryCall <OSImage>((string s) => base.Channel.CreateOSImage(s, LambdaVar23));
                    OSImageContext oSImageContext = new OSImageContext();
                    oSImageContext.AffinityGroup = oSImage2.AffinityGroup;
                    oSImageContext.Category      = oSImage2.Category;
                    oSImageContext.Label         = oSImage2.Label;
                    oSImageContext.Location      = oSImage2.Location;
                    oSImageContext.MediaLink     = oSImage2.MediaLink;
                    oSImageContext.ImageName     = oSImage2.Name;
                    oSImageContext.OS            = oSImage2.OS;
                    OSImageContext oSImageContext1 = oSImageContext;
                    Operation      operation       = base.WaitForOperation(base.CommandRuntime.ToString());
                    oSImageContext1.set_OperationDescription(base.CommandRuntime.ToString());
                    oSImageContext1.set_OperationId(operation.OperationTrackingId);
                    oSImageContext1.set_OperationStatus(operation.Status);
                    base.WriteObject(oSImageContext1, true);
                }
                catch (CommunicationException communicationException1)
                {
                    CommunicationException communicationException = communicationException1;
                    this.WriteErrorDetails(communicationException);
                }
            }
        }
Exemplo n.º 10
0
        public void AzureVMImageTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
            vhdName = "os1.vhd";
            string newImageName  = Utilities.GetUniqueShortName("vmimage");
            string mediaLocation = string.Format("{0}{1}/{2}", blobUrlRoot, vhdContainerName, vhdName);

            string oldLabel = "old label";
            string newLabel = "new label";

            try
            {
                OSImageContext result = vmPowershellCmdlets.AddAzureVMImage(newImageName, mediaLocation, OS.Windows, oldLabel);

                OSImageContext resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                result = vmPowershellCmdlets.UpdateAzureVMImage(newImageName, newLabel);

                resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                vmPowershellCmdlets.RemoveAzureVMImage(newImageName, false);
                Assert.IsTrue(Utilities.CheckRemove(vmPowershellCmdlets.GetAzureVMImage, newImageName));

                pass = true;
            }
            catch (Exception e)
            {
                pass = false;
                Assert.Fail("Exception occurred: {0}", e.ToString());
            }
            finally
            {
                if (!Utilities.CheckRemove(vmPowershellCmdlets.GetAzureVMImage, newImageName))
                {
                    vmPowershellCmdlets.RemoveAzureVMImage(newImageName, false);
                }
            }
        }
Exemplo n.º 11
0
 protected override void ProcessRecord()
 {
     try
     {
         Func <OSImage, OSImageContext> func = null;
         base.ProcessRecord();
         Operation             operation      = null;
         IEnumerable <OSImage> vMImageProcess = this.GetVMImageProcess(out operation);
         if (vMImageProcess != null)
         {
             IEnumerable <OSImage> oSImages = vMImageProcess;
             if (func == null)
             {
                 func = (OSImage d) => {
                     OSImageContext oSImageContext = new OSImageContext();
                     oSImageContext.set_OperationId(operation.OperationTrackingId);
                     oSImageContext.set_OperationDescription(this.CommandRuntime.ToString());
                     oSImageContext.set_OperationStatus(operation.Status);
                     oSImageContext.AffinityGroup   = d.AffinityGroup;
                     oSImageContext.Category        = d.Category;
                     oSImageContext.Label           = d.Label;
                     oSImageContext.Location        = d.Location;
                     oSImageContext.MediaLink       = d.MediaLink;
                     oSImageContext.ImageName       = d.Name;
                     oSImageContext.OS              = d.OS;
                     oSImageContext.LogicalSizeInGB = d.LogicalSizeInGB;
                     return(oSImageContext);
                 }
                 ;
             }
             IEnumerable <OSImageContext> oSImageContexts = oSImages.Select <OSImage, OSImageContext>(func);
             base.WriteObject(oSImageContexts, true);
         }
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         base.WriteError(new ErrorRecord(exception, string.Empty, ErrorCategory.CloseError, null));
     }
 }
Exemplo n.º 12
0
        public void AzureVMImageSizeTest()
        {
            string mediaLocation = UploadVhdFile();
            string newImageName  = Utilities.GetUniqueShortName("vmimage");

            try
            {
                var       instanceSizes        = vmPowershellCmdlets.GetAzureRoleSize().Where(r => r.Cores <= 2 && !r.InstanceSize.StartsWith("Standard_"));
                const int numOfMinimumInstSize = 3;
                Assert.IsTrue(instanceSizes.Count() >= numOfMinimumInstSize);
                var instanceSizesArr = instanceSizes.Take(numOfMinimumInstSize).ToArray();
                int arrayLength      = instanceSizesArr.Count();

                for (int i = 0; i < arrayLength; i++)
                {
                    Utilities.PrintContext(instanceSizesArr[i]);
                    // Add-AzureVMImage test for VM size
                    OSImageContext result         = vmPowershellCmdlets.AddAzureVMImage(newImageName, mediaLocation, OS.Windows, null, instanceSizesArr[i].InstanceSize);
                    OSImageContext resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                    Assert.IsTrue(!string.IsNullOrEmpty(resultReturned.IOType));
                    Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                    // Update-AzureVMImage test for VM size
                    System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10));
                    result         = vmPowershellCmdlets.UpdateAzureVMImage(newImageName, resultReturned.ImageName, instanceSizesArr[Math.Max((i + 1) % arrayLength, 1)].InstanceSize);
                    resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                    Assert.IsTrue(!string.IsNullOrEmpty(resultReturned.IOType));
                    Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                    vmPowershellCmdlets.RemoveAzureVMImage(newImageName);
                    System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10));
                    pass = true;
                }
            }
            catch (Exception e)
            {
                pass = false;
                System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10));
                vmPowershellCmdlets.RemoveAzureVMImage(newImageName, true);
                Console.WriteLine("Exception occurred: {0}", e.ToString());
                throw;
            }
            finally
            {
                try
                {
                    vmPowershellCmdlets.GetAzureVMImage(newImageName);
                    vmPowershellCmdlets.RemoveAzureVMImage(newImageName);
                }
                catch (Exception e)
                {
                    if (e.ToString().Contains("ResourceNotFound"))
                    {
                        Console.WriteLine("The vm image, {0}, is already deleted.", newImageName);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
Exemplo n.º 13
0
        public void AzureVMImageTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
            vhdName = "os1.vhd";
            string newImageName  = Utilities.GetUniqueShortName("vmimage");
            string mediaLocation = string.Format("{0}{1}/{2}", blobUrlRoot, vhdContainerName, vhdName);

            string oldLabel     = "old label";
            string newLabel     = "new label";
            string vmSize       = "Small";
            var    iconUri      = "http://www.bing.com";
            var    smallIconUri = "http://www.bing.com";
            bool   showInGui    = true;

            try
            {
                // BVT Tests for OS Images
                OSImageContext result = vmPowershellCmdlets.AddAzureVMImage(newImageName, mediaLocation, OS.Windows, oldLabel, vmSize, iconUri, smallIconUri, showInGui);

                OSImageContext resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                Assert.IsTrue(!string.IsNullOrEmpty(resultReturned.IOType));
                Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                result         = vmPowershellCmdlets.UpdateAzureVMImage(newImageName, newLabel);
                resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                Assert.IsTrue(!string.IsNullOrEmpty(resultReturned.IOType));
                Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                result         = vmPowershellCmdlets.UpdateAzureVMImage(newImageName, newLabel, true);
                resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                Assert.IsTrue(resultReturned.ShowInGui.HasValue && !resultReturned.ShowInGui.Value);
                Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                vmPowershellCmdlets.RemoveAzureVMImage(newImageName, false);
                Assert.IsTrue(Utilities.CheckRemove(vmPowershellCmdlets.GetAzureVMImage, newImageName));

                // BVT Tests for VM Images
                // Unique Container Prefix
                var containerPrefix = Utilities.GetUniqueShortName("vmimg");

                // Disk Blobs
                var srcVhdName        = "os1.vhd";
                var srcVhdContainer   = vhdContainerName;
                var dstOSVhdContainer = containerPrefix.ToLower() + "os" + vhdContainerName;
                CredentialHelper.CopyTestData(srcVhdContainer, srcVhdName, dstOSVhdContainer);
                string osVhdLink = string.Format("{0}{1}/{2}", blobUrlRoot, dstOSVhdContainer, srcVhdName);

                var dstDataVhdContainer = containerPrefix.ToLower() + "data" + vhdContainerName;
                CredentialHelper.CopyTestData(srcVhdContainer, srcVhdName, dstDataVhdContainer);
                string dataVhdLink = string.Format("{0}{1}/{2}", blobUrlRoot, dstDataVhdContainer, srcVhdName);

                // VM Image OS/Data Disk Configuration
                var addVMImageName = containerPrefix + "Image";
                var diskConfig     = new VirtualMachineImageDiskConfigSet
                {
                    OSDiskConfiguration = new OSDiskConfiguration
                    {
                        HostCaching = HostCaching.ReadWrite.ToString(),
                        OS          = OSType.Windows.ToString(),
                        OSState     = "Generalized",
                        MediaLink   = new Uri(osVhdLink)
                    },
                    DataDiskConfigurations = new DataDiskConfigurationList
                    {
                        new DataDiskConfiguration
                        {
                            HostCaching = HostCaching.ReadOnly.ToString(),
                            Lun         = 0,
                            MediaLink   = new Uri(dataVhdLink)
                        }
                    }
                };

                // Add-AzureVMImage
                string   label             = addVMImageName;
                string   description       = "test";
                string   eula              = "http://www.bing.com/";
                string   imageFamily       = "Windows";
                DateTime?publishedDate     = new DateTime(2015, 1, 1);
                string   privacyUri        = "http://www.bing.com/";
                string   recommendedVMSize = vmSize;
                string   iconName          = "iconName";
                string   smallIconName     = "smallIconName";

                vmPowershellCmdlets.AddAzureVMImage(
                    addVMImageName,
                    label,
                    diskConfig,
                    description,
                    eula,
                    imageFamily,
                    publishedDate,
                    privacyUri,
                    recommendedVMSize,
                    iconName,
                    smallIconName,
                    showInGui);

                // Get-AzureVMImage
                var vmImage = vmPowershellCmdlets.GetAzureVMImageReturningVMImages(addVMImageName).First();

                Assert.IsTrue(vmImage.ImageName == addVMImageName);
                Assert.IsTrue(vmImage.Label == label);
                Assert.IsTrue(vmImage.Description == description);
                Assert.IsTrue(vmImage.Eula == eula);
                Assert.IsTrue(vmImage.ImageFamily == imageFamily);
                Assert.IsTrue(vmImage.PublishedDate.Value.Year == publishedDate.Value.Year);
                Assert.IsTrue(vmImage.PublishedDate.Value.Month == publishedDate.Value.Month);
                Assert.IsTrue(vmImage.PublishedDate.Value.Day == publishedDate.Value.Day);
                Assert.IsTrue(vmImage.PrivacyUri.AbsoluteUri.ToString() == privacyUri);
                Assert.IsTrue(vmImage.RecommendedVMSize == recommendedVMSize);
                Assert.IsTrue(vmImage.IconName == iconName);
                Assert.IsTrue(vmImage.IconUri == iconName);
                Assert.IsTrue(vmImage.SmallIconName == smallIconName);
                Assert.IsTrue(vmImage.SmallIconUri == smallIconName);
                Assert.IsTrue(vmImage.ShowInGui == showInGui);
                Assert.IsTrue(vmImage.OSDiskConfiguration.HostCaching == diskConfig.OSDiskConfiguration.HostCaching);
                Assert.IsTrue(vmImage.OSDiskConfiguration.OS == diskConfig.OSDiskConfiguration.OS);
                Assert.IsTrue(vmImage.OSDiskConfiguration.OSState == diskConfig.OSDiskConfiguration.OSState);
                Assert.IsTrue(vmImage.OSDiskConfiguration.MediaLink == diskConfig.OSDiskConfiguration.MediaLink);
                Assert.IsTrue(vmImage.DataDiskConfigurations.First().HostCaching == diskConfig.DataDiskConfigurations.First().HostCaching);
                Assert.IsTrue(vmImage.DataDiskConfigurations.First().Lun == diskConfig.DataDiskConfigurations.First().Lun);
                Assert.IsTrue(vmImage.DataDiskConfigurations.First().MediaLink == diskConfig.DataDiskConfigurations.First().MediaLink);

                // Remove-AzureVMImage
                vmPowershellCmdlets.RemoveAzureVMImage(addVMImageName);

                pass = true;
            }
            catch (Exception e)
            {
                pass = false;
                Assert.Fail("Exception occurred: {0}", e.ToString());
            }
            finally
            {
                if (!Utilities.CheckRemove(vmPowershellCmdlets.GetAzureVMImage, newImageName))
                {
                    vmPowershellCmdlets.RemoveAzureVMImage(newImageName, false);
                }
            }
        }