public void CloudBlobDirectoryGetParent() { foreach (String delimiter in Delimiters) { CloudBlobClient client = GenerateCloudBlobClient(); client.DefaultDelimiter = delimiter; string name = GetRandomContainerName(); CloudBlobContainer container = client.GetContainerReference(name); try { container.Create(); CloudPageBlob blob = container.GetPageBlobReference("Dir1" + delimiter + "Blob1"); blob.Create(0); Assert.IsTrue(blob.Exists()); Assert.AreEqual("Dir1" + delimiter + "Blob1", blob.Name); CloudBlobDirectory parent = blob.Parent; Assert.AreEqual(parent.Prefix, "Dir1" + delimiter); blob.Delete(); } finally { container.DeleteIfExists(); } } }
/// <summary> /// Wait for the VHD Blob to disappear in order to confirm the VM and its OS disk were deleted. /// </summary> /// <param name="pollIntervalSeconds"></param> /// <param name="action"></param> internal void PollVHDBlob(int pollIntervalSeconds, Action action) { //var account = new CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(_parameters.StorageAccountName, _primaryKey), true); //var client = account.CreateCloudBlobClient(); var blobName = String.Format("https://{0}.blob.core.windows.net/vhds/{1}", _parameters.StorageAccountName, _parameters.VMName); var blob = new CloudPageBlob(new Uri(blobName), new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(_parameters.StorageAccountName, _primaryKey)); while (true) { // Break if the Blob has disappeared if (!blob.Exists()) break; // Execute the action action(); // Wait a while System.Threading.Thread.Sleep(pollIntervalSeconds * 1000); } }