示例#1
0
        public static bool CanAccessSystemDir(out string sysDir)
        {
            WindowsAzureSystemHelper.LogInfo("Can access System Directory?");
            sysDir = string.Empty;
            bool ret = false;
            try
            {
                sysDir = Environment.SystemDirectory;

                WindowsAzureSystemHelper.LogInfo("System Directory is " + sysDir);

                if (!string.IsNullOrEmpty(sysDir))
                    ret = true;
            }
            catch (Exception ex)
            {

                WindowsAzureSystemHelper.LogError("Error in CanAccessSystemDir " + ex.Message);

            }

            return ret;

        }
        /// <summary>
        /// Unmounts the drive
        /// </summary>
        /// <param name="accountName"></param>
        /// <param name="accountKey"></param>
        /// <param name="azureDriveContainerName"></param>
        /// <param name="azureDrivePageBlobName"></param>
        public static void UnmountAzureDrive(string accountName, string accountKey, string azureDriveContainerName, string azureDrivePageBlobName)
        {
            try
            {
                CloudStorageAccount csa = WAStorageHelper.GetCloudStorageAccount(accountName, accountKey, false);
                // Create the blob client

                CloudBlobClient client = csa.CreateCloudBlobClient();
                // Create the blob container which will contain the pageblob corresponding to the azure drive.
                CloudBlobContainer container = client.GetContainerReference(azureDriveContainerName);
                // Get the page blob reference which will be used by the azure drive.
                CloudPageBlob blob = container.GetPageBlobReference(azureDrivePageBlobName);

                CloudDrive drive = new CloudDrive(blob.Uri, csa.Credentials);
                if (drive != null)
                {
                    drive.Unmount();
                }
            }
            catch (Exception ex)
            {
                WindowsAzureSystemHelper.LogError(String.Format("Error unmounting drive with blob {0} - {1}", azureDrivePageBlobName, ex.Message));
            }
        }