/// <summary>
        /// Gets a virtual disk located in blob storage and sets a default size to the disk of 30 GB and a logical unit no. of 0 (drive e:)
        /// </summary>
        /// <param name="storageAccountName">The path to blob storage for the disk</param>
        /// <param name="size">the size of the disk in GB - can be up to 1TB</param>
        /// <param name="logicalUnitNumber">number between 0 and 15 which is the logical unit of the drive</param>
        /// <param name="diskName">the name of the disk</param>
        /// <param name="diskLabel">the label of the disk</param>
        /// <returns></returns>
        public static DataVirtualHardDisk GetDefaultDataDisk(string storageAccountName, int size = 30, int logicalUnitNumber = 0, string diskName = null, string diskLabel = null)
        {
            var namer = new RandomAccountName();

            return(new DataVirtualHardDisk
            {
                LogicalDiskSizeInGB = size,
                LogicalUnitNumber = logicalUnitNumber,
                HostCaching = HostCaching.None,
                DiskLabel = diskLabel,
                DiskName = diskName,
                MediaLink =
                    String.Format("http://{0}.blob.core.windows.net/vhds/{1}-{2}.vhd", storageAccountName,
                                  namer.GetNameFromInitString(diskName), DateTime.Now.ToString("ddmmyy")),
            });
        }
Esempio n. 2
0
        /// <summary>
        /// This gets the host OS image of Windows Server Data Centre and SQL Server 2012
        /// </summary>
        /// <param name="storageAccountName">The path to the media space in blob storage where the host vhd will be placed</param>
        /// <param name="diskName">The name of the C: drive </param>
        /// <param name="diskLabel">The drive volume label for C:</param>
        /// <returns>An OSVirtualHardDisk instance</returns>
        public static OSVirtualHardDisk GetSqlServerOSImage(string storageAccountName, string diskName = null,
                                                            string diskLabel = null)
        {
            /*<OSVirtualHardDisk>
             *          <MediaLink>http://elastacacheweb.blob.core.windows.net/vhds/elastasql.vhd</MediaLink>
             *          <SourceImageName>MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd</SourceImageName>
             *      </OSVirtualHardDisk>*/
            var namer = new RandomAccountName();

            return(new OSVirtualHardDisk
            {
                DiskLabel = diskLabel,
                DiskName = diskName,
                MediaLink =
                    String.Format("http://{0}.blob.core.windows.net/vhds/{1}{2}.vhd", storageAccountName,
                                  namer.GetNameFromInitString("os"), DateTime.Now.ToString("ddmmyy")),
                SourceImageName = "MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd",
                HostCaching = HostCaching.ReadWrite,
            });
        }
        /// <summary>
        /// This gets the host OS image of Windows Server Data Centre and SQL Server 2012
        /// </summary>
        /// <param name="properties">The path to the media space in blob storage where the host vhd will be placed</param>
        /// <returns>An OSVirtualHardDisk instance</returns>
        public static OSVirtualHardDisk GetOSImageFromTemplate(VirtualMachineProperties properties)
        {
            /*<OSVirtualHardDisk>
             *          <MediaLink>http://elastacacheweb.blob.core.windows.net/vhds/elastasql.vhd</MediaLink>
             *          <SourceImageName>MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd</SourceImageName>
             * </OSVirtualHardDisk>*/
            string templateDetails = null;

            string vmType = properties.VirtualMachineType.ToString();

            if (String.IsNullOrEmpty(properties.CustomTemplateName))
            {
                AddVmTemplatesToDictionary();
                if (VmTemplates.ContainsKey(vmType))
                {
                    templateDetails = VmTemplates[vmType];
                }
            }

            if (templateDetails == null && properties.CustomTemplateName == null)
            {
                throw new FluentManagementException("no template specified cannot proceed", "GetOSImageFromTemplate");
            }

            if (properties.CustomTemplateName != null)
            {
                templateDetails = properties.CustomTemplateName;
            }

            return(new OSVirtualHardDisk
            {
                DiskLabel = "OsDisk",
                DiskName = "OsDisk",
                MediaLink = String.Format("http://{0}.blob.core.windows.net/vhds/{1}{2}.vhd", properties.StorageAccountName, Namer.GetNameFromInitString("os"), DateTime.Now.ToString("ddMMyyhhmmss-ffffff")),

                SourceImageName = templateDetails,
                HostCaching = HostCaching.ReadWrite,
            });
        }