public static void MyClassInitialize(TestContext testContext) { Trace.WriteLine("ClassInit"); Test.FullClassName = testContext.FullyQualifiedTestClassName; StorageAccount = TestBase.GetCloudStorageAccountFromConfig(); //init the blob helper for blob related operations BlobHelper = new CloudBlobHelper(StorageAccount); // import module string moduleFilePath = Test.Data.Get("ModuleFilePath"); if (moduleFilePath.Length > 0) PowerShellAgent.ImportModule(moduleFilePath); // $context = New-AzureStorageContext -ConnectionString ... PowerShellAgent.SetStorageContext(StorageAccount.ToString(true)); BlockFilePath = Path.Combine(Test.Data.Get("TempDir"), FileUtil.GetSpecialFileName()); PageFilePath = Path.Combine(Test.Data.Get("TempDir"), FileUtil.GetSpecialFileName()); FileUtil.CreateDirIfNotExits(Path.GetDirectoryName(BlockFilePath)); FileUtil.CreateDirIfNotExits(Path.GetDirectoryName(PageFilePath)); // Generate block file and page file which are used for uploading Helper.GenerateMediumFile(BlockFilePath, 1); Helper.GenerateMediumFile(PageFilePath, 1); }
public static void MyClassInitialize(TestContext testContext) { Trace.WriteLine("ClassInit"); Test.FullClassName = testContext.FullyQualifiedTestClassName; _StorageAccount = TestBase.GetCloudStorageAccountFromConfig(); // import module string moduleFilePath = Test.Data.Get("ModuleFilePath"); if (moduleFilePath.Length > 0) PowerShellAgent.ImportModule(moduleFilePath); // $context = New-AzureStorageContext -ConnectionString ... PowerShellAgent.SetStorageContext(_StorageAccount.ToString(true)); }
/// <summary> /// Gets connection string of the given storage service name. /// </summary> /// <param name="name">The storage service name</param> /// <returns>The connection string</returns> public string GetStorageServiceConnectionString(string name) { StorageService storageService = GetStorageService(name); Debug.Assert(storageService.StorageServiceKeys != null); Debug.Assert(storageService.ServiceName != null); StorageCredentials credentials = new StorageCredentials( storageService.ServiceName, storageService.StorageServiceKeys.Primary); CloudStorageAccount cloudStorageAccount = new CloudStorageAccount( credentials, General.CreateHttpsEndpoint(storageService.StorageServiceProperties.Endpoints[0]), General.CreateHttpsEndpoint(storageService.StorageServiceProperties.Endpoints[1]), General.CreateHttpsEndpoint(storageService.StorageServiceProperties.Endpoints[2]) ); return cloudStorageAccount.ToString(true); }
public static void TestClassInitialize(TestContext testContext) { Test.Info(string.Format("{0} Class Initialize", testContext.FullyQualifiedTestClassName)); Test.FullClassName = testContext.FullyQualifiedTestClassName; StorageAccount = GetCloudStorageAccountFromConfig(); //init the blob helper for blob related operations blobUtil = new CloudBlobUtil(StorageAccount); queueUtil = new CloudQueueUtil(StorageAccount); tableUtil = new CloudTableUtil(StorageAccount); // import module string moduleFilePath = Test.Data.Get("ModuleFilePath"); PowerShellAgent.ImportModule(moduleFilePath); //set the default storage context PowerShellAgent.SetStorageContext(StorageAccount.ToString(true)); random = new Random(); ContainerInitCount = blobUtil.GetExistingContainerCount(); QueueInitCount = queueUtil.GetExistingQueueCount(); TableInitCount = tableUtil.GetExistingTableCount(); }
private void SetApplicationDiagnosticsSettings( string name, WebsiteDiagnosticOutput output, bool setFlag, Dictionary<DiagnosticProperties, object> properties = null) { Site website = GetWebsite(name); using (HttpClient client = CreateDeploymentHttpClient(website.Name)) { DiagnosticsSettings diagnosticsSettings = GetApplicationDiagnosticsSettings(website.Name); switch (output) { case WebsiteDiagnosticOutput.FileSystem: diagnosticsSettings.AzureDriveTraceEnabled = setFlag; diagnosticsSettings.AzureDriveTraceLevel = setFlag ? (LogEntryType)properties[DiagnosticProperties.LogLevel] : diagnosticsSettings.AzureDriveTraceLevel; break; case WebsiteDiagnosticOutput.StorageTable: diagnosticsSettings.AzureTableTraceEnabled = setFlag; if (setFlag) { const string storageTableName = "CLOUD_STORAGE_ACCOUNT"; string storageAccountName = (string)properties[DiagnosticProperties.StorageAccountName]; StorageService storageService = ServiceManagementChannel.GetStorageKeys( subscriptionId, storageAccountName); StorageCredentials credentials = new StorageCredentials( storageAccountName, storageService.StorageServiceKeys.Primary); CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(credentials, false); string connectionString = cloudStorageAccount.ToString(true); AddAppSetting(website.Name, storageTableName, connectionString); diagnosticsSettings.AzureTableTraceLevel = setFlag ? (LogEntryType)properties[DiagnosticProperties.LogLevel] : diagnosticsSettings.AzureTableTraceLevel; } break; default: throw new ArgumentException(); } JObject json = new JObject(); json[UriElements.AzureDriveTraceEnabled] = diagnosticsSettings.AzureDriveTraceEnabled; json[UriElements.AzureDriveTraceLevel] = JToken.FromObject(diagnosticsSettings.AzureDriveTraceLevel); json[UriElements.AzureTableTraceEnabled] = diagnosticsSettings.AzureTableTraceEnabled; json[UriElements.AzureTableTraceLevel] = JToken.FromObject(diagnosticsSettings.AzureTableTraceLevel); client.PostAsJsonAsync(UriElements.DiagnosticsSettings, json, Logger); } }