private static AzureTestCredentials CloneForEnvironment(AzureTestCredentials orig, int index)
 {
     AzureTestCredentials retval = new AzureTestCredentials();
     retval.AzurePassword = orig.AzurePassword;
     retval.AzureUserName = orig.AzureUserName;
     retval.Certificate = orig.Certificate;
     retval.CredentialsName = orig.CredentialsName;
     retval.HadoopUserName = orig.HadoopUserName;
     retval.InvalidCertificate = orig.InvalidCertificate;
     retval.SubscriptionId = orig.SubscriptionId;
     retval.ResourceProviderProperties = orig.ResourceProviderProperties;
     retval.WellKnownCluster = new KnownCluster()
     {
         Cluster = orig.WellKnownCluster.Cluster,
         DnsName = orig.WellKnownCluster.DnsName,
         Version = orig.WellKnownCluster.Version
     };
     retval.Environments = new CreationDetails[0];
     var env = retval.Environments[0] = new CreationDetails();
     var origEnv = orig.Environments[index];
     retval.CloudServiceName = orig.CloudServiceName;
     env.DefaultStorageAccount = new StorageAccountCredentials()
     {
         Container = origEnv.DefaultStorageAccount.Container,
         Key = origEnv.DefaultStorageAccount.Key,
         Name = origEnv.DefaultStorageAccount.Name
     };
     retval.Endpoint = orig.Endpoint;
     env.Location = origEnv.Location;
     retval.EnvironmentType = orig.EnvironmentType;
     List<StorageAccountCredentials> storageAccounts = new List<StorageAccountCredentials>();
     foreach (var storageAccountCredentials in origEnv.AdditionalStorageAccounts)
     {
         var account = new StorageAccountCredentials()
         {
             Container = storageAccountCredentials.Container,
             Key = storageAccountCredentials.Key,
             Name = storageAccountCredentials.Name
         };
         storageAccounts.Add(account);
     }
     env.AdditionalStorageAccounts = storageAccounts.ToArray();
     List<MetastoreCredentials> stores = new List<MetastoreCredentials>();
     foreach (var metastoreCredentials in origEnv.HiveStores)
     {
         var metaStore = new MetastoreCredentials()
         {
             Database = metastoreCredentials.Database,
             Description = metastoreCredentials.Description,
             SqlServer = metastoreCredentials.SqlServer
         };
     }
     env.HiveStores = stores.ToArray();
     stores.Clear();
     foreach (var metastoreCredentials in origEnv.OozieStores)
     {
         var metaStore = new MetastoreCredentials()
         {
             Database = metastoreCredentials.Database,
             Description = metastoreCredentials.Description,
             SqlServer = metastoreCredentials.SqlServer
         };
     }
     env.OozieStores = stores.ToArray();
     return retval;
 }
        private static AzureTestCredentials CloneForEnvironment(AzureTestCredentials orig, int index)
        {
            AzureTestCredentials retval = new AzureTestCredentials();

            retval.AzurePassword              = orig.AzurePassword;
            retval.AzureUserName              = orig.AzureUserName;
            retval.Certificate                = orig.Certificate;
            retval.CredentialsName            = orig.CredentialsName;
            retval.HadoopUserName             = orig.HadoopUserName;
            retval.InvalidCertificate         = orig.InvalidCertificate;
            retval.SubscriptionId             = orig.SubscriptionId;
            retval.ResourceProviderProperties = orig.ResourceProviderProperties;
            retval.WellKnownCluster           = new KnownCluster()
            {
                Cluster = orig.WellKnownCluster.Cluster,
                DnsName = orig.WellKnownCluster.DnsName,
                Version = orig.WellKnownCluster.Version
            };
            retval.Environments = new CreationDetails[0];
            var env     = retval.Environments[0] = new CreationDetails();
            var origEnv = orig.Environments[index];

            retval.CloudServiceName   = orig.CloudServiceName;
            env.DefaultStorageAccount = new StorageAccountCredentials()
            {
                Container = origEnv.DefaultStorageAccount.Container,
                Key       = origEnv.DefaultStorageAccount.Key,
                Name      = origEnv.DefaultStorageAccount.Name
            };
            retval.Endpoint        = orig.Endpoint;
            env.Location           = origEnv.Location;
            retval.EnvironmentType = orig.EnvironmentType;
            List <StorageAccountCredentials> storageAccounts = new List <StorageAccountCredentials>();

            foreach (var storageAccountCredentials in origEnv.AdditionalStorageAccounts)
            {
                var account = new StorageAccountCredentials()
                {
                    Container = storageAccountCredentials.Container,
                    Key       = storageAccountCredentials.Key,
                    Name      = storageAccountCredentials.Name
                };
                storageAccounts.Add(account);
            }
            env.AdditionalStorageAccounts = storageAccounts.ToArray();
            List <MetastoreCredentials> stores = new List <MetastoreCredentials>();

            foreach (var metastoreCredentials in origEnv.HiveStores)
            {
                var metaStore = new MetastoreCredentials()
                {
                    Database    = metastoreCredentials.Database,
                    Description = metastoreCredentials.Description,
                    SqlServer   = metastoreCredentials.SqlServer
                };
            }
            env.HiveStores = stores.ToArray();
            stores.Clear();
            foreach (var metastoreCredentials in origEnv.OozieStores)
            {
                var metaStore = new MetastoreCredentials()
                {
                    Database    = metastoreCredentials.Database,
                    Description = metastoreCredentials.Description,
                    SqlServer   = metastoreCredentials.SqlServer
                };
            }
            env.OozieStores = stores.ToArray();
            return(retval);
        }