public PSStorageAccount(StorageModels.StorageAccount storageAccount) { this.ResourceGroupName = ParseResourceGroupFromId(storageAccount.Id); this.StorageAccountName = storageAccount.Name; this.Id = storageAccount.Id; this.Location = storageAccount.Location; this.Sku = storageAccount.Sku; this.Encryption = storageAccount.Encryption; this.Kind = storageAccount.Kind; this.AccessTier = storageAccount.AccessTier; this.CreationTime = storageAccount.CreationTime; this.CustomDomain = storageAccount.CustomDomain; this.Identity = storageAccount.Identity; this.LastGeoFailoverTime = storageAccount.LastGeoFailoverTime; this.PrimaryEndpoints = storageAccount.PrimaryEndpoints; this.PrimaryLocation = storageAccount.PrimaryLocation; this.ProvisioningState = storageAccount.ProvisioningState; this.SecondaryEndpoints = storageAccount.SecondaryEndpoints; this.SecondaryLocation = storageAccount.SecondaryLocation; this.StatusOfPrimary = storageAccount.StatusOfPrimary; this.StatusOfSecondary = storageAccount.StatusOfSecondary; this.Tags = storageAccount.Tags; this.EnableHttpsTrafficOnly = storageAccount.EnableHttpsTrafficOnly; this.NetworkRuleSet = PSNetworkRuleSet.ParsePSNetworkRule(storageAccount.NetworkAcls); }
public PSStorageAccount(StorageModels.StorageAccount storageAccount) { this.ResourceGroupName = new ResourceIdentifier(storageAccount.Id).ResourceGroupName; this.StorageAccountName = storageAccount.Name; this.Id = storageAccount.Id; this.Location = storageAccount.Location; this.Sku = new PSSku(storageAccount.Sku); this.Encryption = storageAccount.Encryption; this.Kind = storageAccount.Kind; this.AccessTier = storageAccount.AccessTier; this.CreationTime = storageAccount.CreationTime; this.CustomDomain = storageAccount.CustomDomain is null ? null : new PSCustomDomain(storageAccount.CustomDomain); this.Identity = storageAccount.Identity; this.LastGeoFailoverTime = storageAccount.LastGeoFailoverTime; this.PrimaryEndpoints = storageAccount.PrimaryEndpoints; this.PrimaryLocation = storageAccount.PrimaryLocation; this.ProvisioningState = storageAccount.ProvisioningState; this.SecondaryEndpoints = storageAccount.SecondaryEndpoints; this.SecondaryLocation = storageAccount.SecondaryLocation; this.StatusOfPrimary = storageAccount.StatusOfPrimary; this.StatusOfSecondary = storageAccount.StatusOfSecondary; this.Tags = storageAccount.Tags; this.EnableHttpsTrafficOnly = storageAccount.EnableHttpsTrafficOnly; this.NetworkRuleSet = PSNetworkRuleSet.ParsePSNetworkRule(storageAccount.NetworkRuleSet); this.EnableHierarchicalNamespace = storageAccount.IsHnsEnabled; this.FailoverInProgress = storageAccount.FailoverInProgress; this.LargeFileSharesState = storageAccount.LargeFileSharesState; this.AzureFilesIdentityBasedAuth = storageAccount.AzureFilesIdentityBasedAuthentication is null ? null : new PSAzureFilesIdentityBasedAuthentication(storageAccount.AzureFilesIdentityBasedAuthentication); this.GeoReplicationStats = PSGeoReplicationStats.ParsePSGeoReplicationStats(storageAccount.GeoReplicationStats); this.AllowBlobPublicAccess = storageAccount.AllowBlobPublicAccess; this.MinimumTlsVersion = storageAccount.MinimumTlsVersion; this.BlobRestoreStatus = storageAccount.BlobRestoreStatus is null ? null : new PSBlobRestoreStatus(storageAccount.BlobRestoreStatus); }
public PSStorageAccount(StorageModels.StorageAccount storageAccount) { this.ResourceGroupName = new ResourceIdentifier(storageAccount.Id).ResourceGroupName; this.StorageAccountName = storageAccount.Name; this.Id = storageAccount.Id; this.Location = storageAccount.Location; this.Sku = storageAccount.Sku; this.Encryption = storageAccount.Encryption; this.Kind = storageAccount.Kind; this.AccessTier = storageAccount.AccessTier; this.CreationTime = storageAccount.CreationTime; this.CustomDomain = storageAccount.CustomDomain is null ? null : new PSCustomDomain(storageAccount.CustomDomain); this.Identity = storageAccount.Identity; this.LastGeoFailoverTime = storageAccount.LastGeoFailoverTime; this.PrimaryEndpoints = storageAccount.PrimaryEndpoints; this.PrimaryLocation = storageAccount.PrimaryLocation; this.ProvisioningState = storageAccount.ProvisioningState; this.SecondaryEndpoints = storageAccount.SecondaryEndpoints; this.SecondaryLocation = storageAccount.SecondaryLocation; this.StatusOfPrimary = storageAccount.StatusOfPrimary; this.StatusOfSecondary = storageAccount.StatusOfSecondary; this.Tags = storageAccount.Tags; this.EnableHttpsTrafficOnly = storageAccount.EnableHttpsTrafficOnly; this.NetworkRuleSet = PSNetworkRuleSet.ParsePSNetworkRule(storageAccount.NetworkRuleSet); this.EnableHierarchicalNamespace = storageAccount.IsHnsEnabled; this.AzureFilesIdentityBasedAuth = storageAccount.AzureFilesIdentityBasedAuthentication is null ? null : new PSAzureFilesIdentityBasedAuthentication(storageAccount.AzureFilesIdentityBasedAuthentication); }
public static PSStorageAccount Create(StorageAccount storageAccount, IStorageManagementClient client) { var result = new PSStorageAccount(storageAccount); var credentials = StorageUtilities.GenerateStorageCredentials(client, result.ResourceGroupName, result.StorageAccountName); CloudStorageAccount account = new CloudStorageAccount(credentials, storageAccount.PrimaryEndpoints.Blob, storageAccount.PrimaryEndpoints.Queue, storageAccount.PrimaryEndpoints.Table, null); result.Context = new AzureStorageContext(account); return result; }
public static PSStorageAccount Create(StorageModels.StorageAccount storageAccount, IStorageManagementClient client) { var result = new PSStorageAccount(storageAccount); var credentials = StorageUtilities.GenerateStorageCredentials(new ARMStorageProvider(client), result.ResourceGroupName, result.StorageAccountName); CloudStorageAccount account = new CloudStorageAccount(credentials, storageAccount.PrimaryEndpoints.Blob, storageAccount.PrimaryEndpoints.Queue, storageAccount.PrimaryEndpoints.Table, null); result.Context = new AzureStorageContext(account); return(result); }
public static PSStorageAccount Create(StorageModels.StorageAccount storageAccount, IStorageManagementClient client) { var result = new PSStorageAccount(storageAccount); result.Context = new LazyAzureStorageContext((s) => { return((new ARMStorageProvider(client)).GetCloudStorageAccount(s, result.ResourceGroupName)); }, result.StorageAccountName) as AzureStorageContext; return(result); }
internal MediaStorage(string authToken, MediaStorageAccount storageAccount) : base(storageAccount.Type, storageAccount.Id) { TokenCredentials azureToken = AuthToken.AcquireToken(authToken, out string subscriptionId); StorageManagementClient storageClient = new StorageManagementClient(azureToken) { SubscriptionId = subscriptionId }; string accountName = Path.GetFileName(storageAccount.Id); IEnumerable <StorageAccount> storageAccounts = storageClient.StorageAccounts.List(); storageAccounts = storageAccounts.Where(s => s.Name.Equals(accountName, StringComparison.OrdinalIgnoreCase)); _storageAccount = storageAccounts.SingleOrDefault(); }
internal MediaStorage(MediaAccount mediaAccount, MediaStorageAccount storageAccount) : base(storageAccount.Type, storageAccount.Id) { ServiceClientCredentials clientCredentials = ApplicationTokenProvider.LoginSilentAsync(mediaAccount.DirectoryTenantId, mediaAccount.ServicePrincipalId, mediaAccount.ServicePrincipalKey).Result; StorageManagementClient storageClient = new StorageManagementClient(clientCredentials) { SubscriptionId = mediaAccount.SubscriptionId }; _storageAccountName = Path.GetFileName(storageAccount.Id); IEnumerable <StorageAccount> storageAccounts = storageClient.StorageAccounts.List(); storageAccounts = storageAccounts.Where(s => s.Name.Equals(_storageAccountName, StringComparison.OrdinalIgnoreCase)); _storageAccount = storageAccounts.SingleOrDefault(); }
public static PSStorageAccount Create(StorageModels.StorageAccount storageAccount, IStorageManagementClient client) { var result = new PSStorageAccount(storageAccount); result.Context = new LazyAzureStorageContext((s) => { var credentials = StorageUtilities.GenerateStorageCredentials(new ARMStorageProvider(client), result.ResourceGroupName, s); return(new CloudStorageAccount(credentials, ARMStorageService.GetUri(storageAccount.PrimaryEndpoints.Blob), ARMStorageService.GetUri(storageAccount.PrimaryEndpoints.Queue), ARMStorageService.GetUri(storageAccount.PrimaryEndpoints.Table), ARMStorageService.GetUri(storageAccount.PrimaryEndpoints.File))); }, result.StorageAccountName) as AzureStorageContext; return(result); }
public PSStorageAccount(StorageAccount storageAccount) { this.ResourceGroupName = ParseResourceGroupFromId(storageAccount.Id); this.Name = storageAccount.Name; this.Id = storageAccount.Id; this.Location = storageAccount.Location; this.AccountType = storageAccount.AccountType; this.CreationTime = storageAccount.CreationTime; this.CustomDomain = storageAccount.CustomDomain; this.LastGeoFailoverTime = storageAccount.LastGeoFailoverTime; this.PrimaryEndpoints = storageAccount.PrimaryEndpoints; this.PrimaryLocation = storageAccount.PrimaryLocation; this.ProvisioningState = storageAccount.ProvisioningState; this.SecondaryEndpoints = storageAccount.SecondaryEndpoints; this.SecondaryLocation = storageAccount.SecondaryLocation; this.StatusOfPrimary = storageAccount.StatusOfPrimary; this.StatusOfSecondary = storageAccount.StatusOfSecondary; this.Tags = storageAccount.Tags; }
public PSStorageAccount(StorageModels.StorageAccount storageAccount) { this.ResourceGroupName = ParseResourceGroupFromId(storageAccount.Id); this.StorageAccountName = storageAccount.Name; this.Id = storageAccount.Id; this.Location = storageAccount.Location; this.AccountType = storageAccount.AccountType; this.CreationTime = storageAccount.CreationTime; this.CustomDomain = storageAccount.CustomDomain; this.LastGeoFailoverTime = storageAccount.LastGeoFailoverTime; this.PrimaryEndpoints = storageAccount.PrimaryEndpoints; this.PrimaryLocation = storageAccount.PrimaryLocation; this.ProvisioningState = storageAccount.ProvisioningState; this.SecondaryEndpoints = storageAccount.SecondaryEndpoints; this.SecondaryLocation = storageAccount.SecondaryLocation; this.StatusOfPrimary = storageAccount.StatusOfPrimary; this.StatusOfSecondary = storageAccount.StatusOfSecondary; this.Tags = storageAccount.Tags; }
public static void VerifyAccountProperties(StorageAccount account, bool useDefaults) { Assert.NotNull(account.Id); Assert.NotNull(account.Location); Assert.NotNull(account.Name); Assert.NotNull(account); Assert.NotNull(account.AccountType); Assert.NotNull(account.CreationTime); Assert.Equal(AccountStatus.Available, account.StatusOfPrimary); Assert.Equal(account.Location, account.PrimaryLocation); Assert.NotNull(account.PrimaryEndpoints); Assert.NotNull(account.PrimaryEndpoints.Blob); if (account.AccountType != AccountType.StandardZRS && account.AccountType != AccountType.PremiumLRS) { Assert.NotNull(account.PrimaryEndpoints.Queue); Assert.NotNull(account.PrimaryEndpoints.Table); } Assert.Equal(Microsoft.Azure.Management.Storage.Models.ProvisioningState.Succeeded, account.ProvisioningState); Assert.Null(account.LastGeoFailoverTime); switch (account.AccountType) { case AccountType.StandardLRS: case AccountType.StandardZRS: case AccountType.PremiumLRS: Assert.Equal("", account.SecondaryLocation); // TODO: make null when service is fixed Assert.Null(account.StatusOfSecondary); Assert.Null(account.SecondaryEndpoints); break; case AccountType.StandardRAGRS: Assert.Equal(AccountStatus.Available, account.StatusOfSecondary); Assert.NotNull(account.SecondaryLocation); Assert.NotNull(account.SecondaryEndpoints); Assert.NotNull(account.SecondaryEndpoints.Blob); Assert.NotNull(account.SecondaryEndpoints.Queue); Assert.NotNull(account.SecondaryEndpoints.Table); break; case AccountType.StandardGRS: Assert.Equal(AccountStatus.Available, account.StatusOfSecondary); Assert.NotNull(account.SecondaryLocation); Assert.Null(account.SecondaryEndpoints); break; } if (useDefaults) { Assert.Equal(StorageManagementTestUtilities.DefaultLocation, account.Location); Assert.Equal(StorageManagementTestUtilities.DefaultAccountType, account.AccountType); Assert.NotNull(account.Tags); Assert.Equal(2, account.Tags.Count); Assert.Equal(account.Tags["key1"], "value1"); Assert.Equal(account.Tags["key2"], "value2"); } }
protected void WriteStorageAccount(StorageModels.StorageAccount storageAccount) { WriteObject(PSStorageAccount.Create(storageAccount, this.StorageClient)); }
private static bool TryGetStorageAccount(IStorageManagementClient storageClient, string storageAccountName, out StorageAccount storageAccount) { try { var storageAccounts = storageClient.StorageAccounts.List().StorageAccounts; storageAccount = storageAccounts == null ? null : storageAccounts.FirstOrDefault(account => account.Name.Equals(storageAccountName)); } catch { storageAccount = null; } return storageAccount != null; }
protected VirtualMachine CreateVM_NoAsyncTracking( string rgName, string asName, StorageAccount storageAccount, ImageReference imageRef, out VirtualMachine inputVM, Action<VirtualMachine> vmCustomizer = null, bool createWithPublicIpAddress = false) { try { // Create the resource Group, it might have been already created during StorageAccount creation. var resourceGroup = m_ResourcesClient.ResourceGroups.CreateOrUpdate( rgName, new ResourceGroup { Location = m_location }); PublicIpAddressGetResponse getPublicIpAddressResponse = createWithPublicIpAddress ? null : CreatePublicIP(rgName); SubnetGetResponse subnetResponse = CreateVNET(rgName); NetworkInterfaceGetResponse nicResponse = CreateNIC( rgName, subnetResponse.Subnet, getPublicIpAddressResponse != null ? getPublicIpAddressResponse.PublicIpAddress : null); string asetId = CreateAvailabilitySet(rgName, asName); inputVM = CreateDefaultVMInput(rgName, storageAccount.Name, imageRef, asetId, nicResponse.NetworkInterface.Id); if (vmCustomizer != null) { vmCustomizer(inputVM); } string expectedVMReferenceId = Helpers.GetVMReferenceId(m_subId, rgName, inputVM.Name); var createOrUpdateResponse = m_CrpClient.VirtualMachines.BeginCreatingOrUpdating( rgName, inputVM); Assert.True(createOrUpdateResponse.StatusCode == HttpStatusCode.Created); Assert.True(createOrUpdateResponse.VirtualMachine.Name == inputVM.Name); Assert.True(createOrUpdateResponse.VirtualMachine.Location == inputVM.Location.ToLower().Replace(" ", "") || createOrUpdateResponse.VirtualMachine.Location.ToLower() == inputVM.Location.ToLower()); Assert.True( createOrUpdateResponse.VirtualMachine.AvailabilitySetReference.ReferenceUri .ToLowerInvariant() == asetId.ToLowerInvariant()); ValidateVM(inputVM, createOrUpdateResponse.VirtualMachine, expectedVMReferenceId); var operationUri = new Uri(createOrUpdateResponse.AzureAsyncOperation); string operationId = operationUri.Segments.LastOrDefault(); var lroResponse = m_CrpClient.GetLongRunningOperationStatus(createOrUpdateResponse.AzureAsyncOperation.ToString()); ValidateLROResponse(lroResponse, operationId); // CONSIDER dropping this Get and ValidateVM call. Nothing changes in the VM model after it's accepted. // There might have been intent to track the async operation to completion and then check the VM is // still this and okay, but that's not what the code above does and still doesn't make much sense. var getResponse = m_CrpClient.VirtualMachines.Get(rgName, inputVM.Name); Assert.True(getResponse.StatusCode == HttpStatusCode.OK); ValidateVM(inputVM, getResponse.VirtualMachine, expectedVMReferenceId); return getResponse.VirtualMachine; } catch { var deleteRg1Response = m_ResourcesClient.ResourceGroups.Delete(rgName); Assert.True(deleteRg1Response.StatusCode == HttpStatusCode.OK); throw; } }
/// <summary> /// Make sure the storage account key is set. /// If user doesn't specify it in command line, we try to resolve the key for the user given the storage account. /// </summary> /// <param name="storageAccount">The storage account to list the key.</param> private void InitializeStorageAccountKey(StorageAccount storageAccount) { if (string.IsNullOrEmpty(this.StorageAccountKey)) { if (storageAccount == null) { throw new Exception(string.Format(CultureInfo.InvariantCulture, Properties.Resources.DiagnosticsExtensionFailedToListKeyForNoStorageAccount, this.StorageAccountName)); } var psStorageAccount = new PSStorageAccount(storageAccount); var credentials = StorageUtilities.GenerateStorageCredentials(this.StorageClient, psStorageAccount.ResourceGroupName, psStorageAccount.StorageAccountName); this.StorageAccountKey = credentials.ExportBase64EncodedKey(); } }
/// <summary> /// Make sure we set the correct storage account endpoint. /// We can get the value from multiple places, we only take the one with higher precedence. And the precedence is: /// 1. Directly specified from command line parameter /// 2. The one get from StorageContext parameter /// 3. The one get from the storage account we list /// 4. The one get from current Azure Environment /// </summary> /// <param name="storageAccount">The storage account to help get the endpoint.</param> private void InitializeStorageAccountEndpoint(StorageAccount storageAccount) { if (string.IsNullOrEmpty(this.StorageAccountEndpoint)) { var context = this.StorageContext; if (context == null) { Uri blobEndpoint = null, queueEndpoint = null, tableEndpoint = null, fileEndpoint = null; if (storageAccount != null) { // Create storage context from storage account var endpoints = storageAccount.PrimaryEndpoints; blobEndpoint = endpoints.Blob; queueEndpoint = endpoints.Queue; tableEndpoint = endpoints.Table; fileEndpoint = endpoints.File; } else if (this.DefaultContext != null && this.DefaultContext.Environment != null) { // Create storage context from default azure environment. Default to use https blobEndpoint = DefaultContext.Environment.GetStorageBlobEndpoint(this.StorageAccountName); queueEndpoint = DefaultContext.Environment.GetStorageQueueEndpoint(this.StorageAccountName); tableEndpoint = DefaultContext.Environment.GetStorageTableEndpoint(this.StorageAccountName); fileEndpoint = DefaultContext.Environment.GetStorageFileEndpoint(this.StorageAccountName); } else { // Can't automatically get the endpoint to create storage context throw new ArgumentNullException(Properties.Resources.DiagnosticsExtensionStorageAccountEndpointNotDefined); } var credentials = new StorageCredentials(this.StorageAccountName, this.StorageAccountKey); var cloudStorageAccount = new CloudStorageAccount(credentials, blobEndpoint, queueEndpoint, tableEndpoint, fileEndpoint); context = new AzureStorageContext(cloudStorageAccount); } var scheme = context.BlobEndPoint.StartsWith("https://", StringComparison.OrdinalIgnoreCase) ? "https://" : "http://"; this.StorageAccountEndpoint = scheme + context.EndPointSuffix; } }
protected void WriteStorageAccount(StorageAccount storageAccount) { WriteObject(new PSStorageAccount(storageAccount)); }
internal string GetAzureSAPTableEndpoint(StorageAccount storage) { return storage.PrimaryEndpoints.Table.ToString(); }
protected void WriteStorageAccount(StorageAccount storageAccount) { WriteObject(PSStorageAccount.Create(storageAccount, this.StorageClient)); }
protected VirtualMachine CreateVM(string rgName, string asName, StorageAccount storageAccount, string imgRefId, out VirtualMachine inputVM, Action<VirtualMachine> vmCustomizer = null, bool createWithPublicIpAddress = false) { try { // Create the resource Group, it might have been already created during StorageAccount creation. var resourceGroup = m_ResourcesClient.ResourceGroups.CreateOrUpdate( rgName, new ResourceGroup { Location = m_location }); PublicIpAddressGetResponse getPublicIpAddressResponse = createWithPublicIpAddress ? null : CreatePublicIP(rgName); SubnetGetResponse subnetResponse = CreateVNET(rgName); NetworkInterfaceGetResponse nicResponse = CreateNIC(rgName, subnetResponse.Subnet, getPublicIpAddressResponse.PublicIpAddress); string asetId = CreateAvailabilitySet(rgName, asName); inputVM = CreateDefaultVMInput(rgName, storageAccount.Name, imgRefId, asetId, nicResponse.NetworkInterface.Id); if (vmCustomizer != null) { vmCustomizer(inputVM); } string expectedVMReferenceId = Helpers.GetVMReferenceId(m_subId, rgName, inputVM.Name); var createOrUpdateResponse = m_CrpClient.VirtualMachines.BeginCreatingOrUpdating ( rgName, inputVM); Assert.True(createOrUpdateResponse.StatusCode == HttpStatusCode.Created); Assert.True(createOrUpdateResponse.VirtualMachine.Name == inputVM.Name); Assert.True(createOrUpdateResponse.VirtualMachine.Location == inputVM.Location.ToLower().Replace(" ", "") || createOrUpdateResponse.VirtualMachine.Location.ToLower() == inputVM.Location.ToLower()); Assert.True( createOrUpdateResponse.VirtualMachine.AvailabilitySetReference.ReferenceUri .ToLowerInvariant() == asetId.ToLowerInvariant()); ValidateVM(inputVM, createOrUpdateResponse.VirtualMachine, expectedVMReferenceId); var operationUri = new Uri(createOrUpdateResponse.AzureAsyncOperation); string operationId = operationUri.Segments.LastOrDefault(); var lroResponse = m_CrpClient.GetLongRunningOperationStatus(createOrUpdateResponse.AzureAsyncOperation.ToString()); ValidateLROResponse(lroResponse, operationId); var getResponse = m_CrpClient.VirtualMachines.Get(rgName, inputVM.Name); Assert.True(getResponse.StatusCode == HttpStatusCode.OK); ValidateVM(inputVM, getResponse.VirtualMachine, expectedVMReferenceId); return getResponse.VirtualMachine; } catch { var deleteRg1Response = m_ResourcesClient.ResourceGroups.Delete(rgName); Assert.True(deleteRg1Response.StatusCode == HttpStatusCode.OK); throw; } }
internal bool IsPremiumStorageAccount(StorageAccount account) { if (account.AccountType.HasValue) { return (account.AccountType.Value.ToString().StartsWith("Premium")); } WriteError("No AccountType for storage account {0} found", account.Name); throw new ArgumentException("No AccountType for storage account found"); }
public void ValidateSRPAccount(string resourceGroupName, string accountName, string location = null, string skuName = null, Hashtable[] tags = null, Kind kind = Kind.Storage, AccessTier?accessTier = null, string customDomain = null, bool?useSubdomain = null, Constants.EncryptionSupportServiceEnum enableEncryptionService = Constants.EncryptionSupportServiceEnum.Blob | Constants.EncryptionSupportServiceEnum.File, bool?enableHttpsTrafficOnly = null, bool AssignIdentity = false, bool StorageEncryption = false, bool keyvaultEncryption = false, string keyName = null, string keyVersion = null, string keyVaultUri = null) { AzureOperationResponse <SRPModel.StorageAccount> response = this.SRPStorageClient.StorageAccounts.GetPropertiesWithHttpMessagesAsync(resourceGroupName, accountName).Result; Test.Assert(response.Response.StatusCode == HttpStatusCode.OK, string.Format("Account {0} should be created successfully.", accountName)); SRPModel.StorageAccount account = response.Body; Test.Assert(accountName == account.Name, string.Format("Expected account name is {0} and actually it is {1}", accountName, account.Name)); if (!string.IsNullOrEmpty(skuName)) { Test.Assert(this.mapAccountType(Constants.AccountTypes[(int)account.Sku.Name]).Equals(skuName), string.Format("Expected account type is {0} and actually it is {1}", skuName, account.Sku.Name)); } if (!string.IsNullOrEmpty(location)) { Test.Assert(location.Replace(" ", "").ToLower() == account.Location, string.Format("Expected location is {0} and actually it is {1}", location, account.Location)); } Test.Assert(kind == account.Kind, string.Format("Kind should match: {0} == {1}", kind, account.Kind)); //for StorageV2 account, will have default accesstier as cool if (kind == Kind.StorageV2 && accessTier == null) { accessTier = AccessTier.Cool; } Test.Assert(accessTier == account.AccessTier || (account.Kind == Kind.StorageV2 && account.AccessTier == AccessTier.Hot), string.Format("AccessTier should match: {0} == {1}", accessTier, account.AccessTier)); if (customDomain == null) { Test.Assert(account.CustomDomain == null, string.Format("CustomDomain should match: {0} == {1}", customDomain, account.CustomDomain)); } else { Test.Assert(customDomain == account.CustomDomain.Name, string.Format("CustomDomain should match: {0} == {1}", customDomain, account.CustomDomain.Name)); // UseSubDomain is only for set, and won't be return in get Test.Assert(account.CustomDomain.UseSubDomain == null, string.Format("UseSubDomain should match: {0} == {1}", null, account.CustomDomain.UseSubDomain)); } if (enableHttpsTrafficOnly != null) { Test.Assert(enableHttpsTrafficOnly == account.EnableHttpsTrafficOnly, string.Format("EnableHttpsTrafficOnly should match: {0} == {1}", enableHttpsTrafficOnly, account.EnableHttpsTrafficOnly)); } if (AssignIdentity) { Test.Assert(account.Identity != null, string.Format("IdentityType should not be null: {0}, {1}", account.Identity.PrincipalId, account.Identity.TenantId)); } this.ValidateTags(tags, account.Tags); ValidateServiceEncrption(account.Encryption, enableEncryptionService, StorageEncryption, keyvaultEncryption, keyName, keyVersion, keyVaultUri); }