當前位置: 首頁>>代碼示例>>C#>>正文


C# WindowsAzure.CloudStorageAccount類代碼示例

本文整理匯總了C#中Microsoft.WindowsAzure.CloudStorageAccount的典型用法代碼示例。如果您正苦於以下問題:C# CloudStorageAccount類的具體用法?C# CloudStorageAccount怎麽用?C# CloudStorageAccount使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CloudStorageAccount類屬於Microsoft.WindowsAzure命名空間,在下文中一共展示了CloudStorageAccount類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetTableStream

        private Stream GetTableStream(CloudStorageAccount account, string tableName, string query)
        {
            var requestUri = new StringBuilder();
            requestUri.AppendFormat("{0}{1}()", account.TableEndpoint.ToString(), tableName);
            if (String.IsNullOrWhiteSpace(query))
            {
                requestUri.AppendFormat("?{0}", query);
            }

            // create Http Request
            var request = (HttpWebRequest)HttpWebRequest.Create(requestUri.ToString());

            // For requests using the $select query option, the request must be made using version 2011-08-18
            // or newer. In addition, the DataServiceVersion and MaxDataServiceVersion headers must be set
            // to 2.0.
            // http://msdn.microsoft.com/en-us/library/dd179421.aspx
            request.Headers.Add("x-ms-version", "2011-08-18");
            request.Headers.Add("MaxDataServiceVersion", "2.0");

            // signs request using the specified credentials under the Shared Key Lite authentication
            account.Credentials.SignRequestLite(request);

            var response = (HttpWebResponse)request.GetResponse();

            // get stream from response with response encoding
            var sr = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(response.CharacterSet));

            return sr.BaseStream;
        }
開發者ID:takekazuomi,項目名稱:was20110818,代碼行數:29,代碼來源:StorageRequest.cs

示例2: PushServiceTokenRepository

 public PushServiceTokenRepository()
 {
     storage = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
     client = storage.CreateCloudTableClient();
     client.CreateTableIfNotExist(TableName);
     context = client.GetDataServiceContext();
 }
開發者ID:mchambers,項目名稱:Daremeto,代碼行數:7,代碼來源:PushServiceTokenRepository.cs

示例3: Storage

        public Storage(CloudStorageAccount account)
        {
            this.account = account;

            fileStorage = account.CreateCloudBlobClient();

            /* Initialize file container */
            container = fileStorage.GetContainerReference(filesContainer);
            container.CreateIfNotExist();

            var permissions = container.GetPermissions();
            /* Full permissions. From MSDN, Container-level public access. Anonymous clients can
             * read blob content and metadata and container metadata, and can list the blobs within the container.
             *
             * Other alternatives are Blob (can read content but not metadata) and Off (no
             * anonymous access).
             */
            // permissions.PublicAccess = BlobContainerPublicAccessType.Container;
            permissions.PublicAccess = BlobContainerPublicAccessType.Off;

            permissions.SharedAccessPolicies.Remove("basic");
            permissions.SharedAccessPolicies.Add("basic", new SharedAccessPolicy()
            {
            });

            container.SetPermissions(permissions);

            /* Initialize table (for file metadata) */
            CloudTableClient.CreateTablesFromModel(
                typeof(FileDataContext),
                account.TableEndpoint.AbsoluteUri,
                account.Credentials);
        }
開發者ID:davidajulio,項目名稱:claims,代碼行數:33,代碼來源:Storage.cs

示例4: AzureEventStore

        public AzureEventStore(CloudStorageAccount storageAccount)
        {
            _account = storageAccount;
            _tableClient = _account.CreateCloudTableClient();

            InitializeStorage();
        }
開發者ID:SzymonPobiega,項目名稱:ncqrs,代碼行數:7,代碼來源:AzureEventStore.cs

示例5: InitializeCloudStorage

        public static void InitializeCloudStorage(CloudStorageAccount account)
        {
            CloudTableClient cloudTableClient = account.CreateCloudTableClient();
            CloudQueueClient cloudQueueClient = account.CreateCloudQueueClient();

            CreateUserPrivilegeTable(cloudTableClient);
        }
開發者ID:kirpasingh,項目名稱:MicrosoftAzureTrainingKit,代碼行數:7,代碼來源:CloudStorageInitializer.cs

示例6: Patch

 private CloudStorageAccount Patch(CloudStorageAccount account)
 {
     ServicePointManager.FindServicePoint(account.BlobEndpoint).UseNagleAlgorithm = false;
     ServicePointManager.FindServicePoint(account.TableEndpoint).UseNagleAlgorithm = false;
     ServicePointManager.FindServicePoint(account.QueueEndpoint).UseNagleAlgorithm = false;
     return account;
 }
開發者ID:npickett,項目名稱:lokad-cloud-storage,代碼行數:7,代碼來源:AzureStorageModule.cs

示例7: AzureStorageProvider

        public AzureStorageProvider(CloudStorageAccount storageAccount)
        {
            cloudStorageAccount = storageAccount;

            // Create the blob client
            blobStorage = cloudStorageAccount.CreateCloudBlobClient();
        }
開發者ID:CloudMorph,項目名稱:CloudMorph,代碼行數:7,代碼來源:AzureStorageProvider.cs

示例8: Install

		public void Install(IPaths paths, CloudStorageAccount storageAccount, int port, ICloudDriveManager cloudDriveManager)
		{
			Trace.TraceInformation("Installing Neo4j server.");

			DownloadJava(paths, storageAccount);
            UnzipJava(paths);

			DownloadNeo4j(paths, storageAccount);
			UnzipNeo4j(paths);

            try
            {
                // try to mount cloud drive
                MountDatabase(paths, cloudDriveManager);
                SetServerDbPathConfig(paths, port);
            }
            catch (Exception ex)
            {
                Trace.TraceError("Drive Mounting Error: " + ex.Message);
            }
            
			SetServerPortAndUrlConfig(paths, port);
			SetJavaPath(paths);
			CopyConfigurationFilesToLogsDirectory(paths);

			ClearLogDirectory(paths);

			Trace.TraceInformation("Neo4j server installed.");
		}
開發者ID:jonbgallant,項目名稱:Neo4j.Azure.Server,代碼行數:29,代碼來源:Neo4jManager.cs

示例9: AzureStorageServiceBase

 static AzureStorageServiceBase()
 {
     if (RoleEnvironment.IsEmulated)
         storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
     else
         storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(StorageConnectionString));
 }
開發者ID:jacklau88,項目名稱:Forms,代碼行數:7,代碼來源:AzureStorageServiceBase.cs

示例10: CopyBlockBlob

        /// <summary>
        /// Copies a blob from one account and container to another.
        /// </summary>
        /// <param name="copyBlockBlobSettings">A <see cref="CopyBlockBlobSettings"/>.</param>
        public static void CopyBlockBlob(CopyBlockBlobSettings copyBlockBlobSettings)
        {
            Contract.Requires(copyBlockBlobSettings != null, "The copy block blob settings cannot be null.");

            var sourceStorageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(copyBlockBlobSettings.BlobStorageSource, copyBlockBlobSettings.BlobStorageSourceKey), copyBlockBlobSettings.UseHttps);
            var sourceClient = sourceStorageAccount.CreateCloudBlobClient();
            var destinationStorageAccount = new CloudStorageAccount(new StorageCredentialsAccountAndKey(copyBlockBlobSettings.BlobStorageDestination, copyBlockBlobSettings.BlobStorageDestinationKey), copyBlockBlobSettings.UseHttps);
            var destinationClient = destinationStorageAccount.CreateCloudBlobClient();
            var destinationContainer = destinationClient.GetContainerReference(copyBlockBlobSettings.DestinationContainerName);

            try
            {
                destinationContainer.CreateIfNotExist();
            }
            catch
            {
                // do nothing, create if not exists blows up if it already exists... nice.
            }

            var sourceBlob = sourceClient.GetBlockBlobReference(copyBlockBlobSettings.BlobSourcePath);
            sourceBlob.FetchAttributes();

            CloudBlob destinationBlob = destinationClient.GetBlockBlobReference(copyBlockBlobSettings.BlobDestinationPath);

            destinationBlob.StartCopyFromBlob(sourceBlob.Uri);

            MonitorCopy(destinationBlob.Container);
        }
開發者ID:amido,項目名稱:Amido.Testing,代碼行數:32,代碼來源:BlobStorage.cs

示例11: WorkerRoleLoader

        public WorkerRoleLoader()
        {
            this.LastModified = DateTime.MinValue;

            this.storageAccount = CloudStorageAccount.FromConfigurationSetting(DataConfigurationKey);
            this.blobStorage = storageAccount.CreateCloudBlobClient();
        }
開發者ID:southworks,項目名稱:workerroleaccelerator,代碼行數:7,代碼來源:WorkerRoleLoader.cs

示例12: InitializeStorage

        internal static bool InitializeStorage()
        {
            try
            {
                // 僅為測試目的,如果我們不在計算仿真程序中運行該服務,我們始終使用 dev 存儲.
                if (RoleEnvironment.IsAvailable)
                {
                    CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
                    {
                        configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
                    });
                    StorageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
                }
                else
                {
                    StorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
                }

                CloudBlobClient blobClient = new CloudBlobClient(StorageAccount.BlobEndpoint, StorageAccount.Credentials);
                CloudBlobContainer container = blobClient.GetContainerReference("videostories");
                container.CreateIfNotExist();
                CloudQueueClient queueClient = new CloudQueueClient(StorageAccount.QueueEndpoint, StorageAccount.Credentials);
                CloudQueue queue = queueClient.GetQueueReference("videostories");
                queue.CreateIfNotExist();
                CloudTableClient tableClient = new CloudTableClient(StorageAccount.TableEndpoint.AbsoluteUri, StorageAccount.Credentials);
                tableClient.CreateTableIfNotExist("Stories");
                return true;
            }
            catch (Exception ex)
            {
                Trace.Write("錯誤初始化存儲: " + ex.Message, "Error");
                return false;
            }
        }
開發者ID:zealoussnow,項目名稱:OneCode,代碼行數:34,代碼來源:Global.asax.cs

示例13: AddAilmentDetails

        //ADD AILMENT DETAILS
        public void AddAilmentDetails(AilmentDetails AilData)
        {
            #if DEBUG
            account = CloudStorageAccount.DevelopmentStorageAccount;
            #else
            account = new CloudStorageAccount(accountAndKey, true);
            #endif
            client = account.CreateCloudTableClient();
            client.CreateTableIfNotExist("PatientDetails");
            tableContext = new TableServiceContext(account.TableEndpoint.ToString(), account.Credentials);

            AilmentDetails x = new AilmentDetails();
            x.AttendingPhysician = AilData.AttendingPhysician;
            x.Diagnosis = AilData.Diagnosis;
            x.DiagnosisID = AilData.DiagnosisID;
            x.GeneralPhysician = AilData.GeneralPhysician;
            x.Hospital = AilData.Hospital;
            x.Lab_Pathology = AilData.Lab_Pathology;
            x.Lab_Physical = AilData.Lab_Physical;
            x.Lab_Radiology = AilData.Lab_Physical;
            x.Medication = AilData.Medication;
            x.PatientIDLinkRowKey = AilData.PatientIDLinkRowKey;
            x.ProgressNotes = AilData.ProgressNotes;
            x.Symptoms = AilData.Symptoms;
            x.TimeIn = AilData.TimeIn;
            x.TimeOut = AilData.TimeOut;
            x.Treatment = AilData.Treatment;
            x.AilmentDetailRowKey = AilData.AilmentDetailRowKey;

            tableContext.AddObject("PatientDetails", x);
            tableContext.SaveChanges();
        }
開發者ID:cloudscrubs,項目名稱:azureprototype,代碼行數:33,代碼來源:Service1.svc.cs

示例14: OnInitialize

        private void OnInitialize()
        {
            var selfInstance        = InstanceEnumerator.GetSelf();

            cloudStorageAccount     = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(ConfigurationSettingsKeys.StorageConnectionString));
            log.Info("Storage account selected: {0}",cloudStorageAccount.BlobEndpoint);
            
            cloudBlobClient         = cloudStorageAccount.CreateCloudBlobClient();
            log.Info("Storage client created");

            var containerName       = ConfigurationProvider.GetSetting(ConfigurationSettingsKeys.StorageContainerName,"ravendb");

            // In order to force a connection we just enumerate all available containers:
            var availableContainers = cloudBlobClient.ListContainers().ToArray();

            foreach (var container in availableContainers)
            {
                log.Info("Available container: {0}",container.Name);
            }

            if (!availableContainers.Any(c => c.Name.Equals(containerName)))
            {
                log.Info("Container {0} does not exist, creating",containerName);

                // Container does not exist:
                cloudBlobClient.GetContainerReference(containerName).Create();
            }

            cloudBlobContainer      = cloudBlobClient.GetContainerReference(containerName);
            log.Info("Container {0} selected",cloudBlobContainer.Name);

            localCache              = RoleEnvironment.GetLocalResource(ConfigurationSettingsKeys.StorageCacheResource);
            log.Info("Cache resource retrieved: {0}, path: {1}",localCache.Name,localCache.RootPath);
            CloudDrive.InitializeCache(localCache.RootPath, localCache.MaximumSizeInMegabytes);
            log.Info("Cache initialized: {0} mb",localCache.MaximumSizeInMegabytes);

            var driveName           = string.Format("{0}{1}.vhd", selfInstance.RoleName, selfInstance.RoleInstanceIndex).ToLowerInvariant();
            log.Info("Virtual drive name: {0}",driveName);
            
            var pageBlob            = cloudBlobContainer.GetPageBlobReference(driveName);
            log.Info("Virtual drive blob: {0}",pageBlob.Uri);

            cloudDrive              = cloudStorageAccount.CreateCloudDrive(pageBlob.Uri.ToString());
            log.Info("Virtual drive created: {0}",cloudDrive.Uri);

            var storageSize         = ConfigurationProvider.GetSetting(ConfigurationSettingsKeys.StorageSizeInMb, 50000);
            log.Info("Storage size: {0} mb",storageSize);

            cloudDrive.CreateIfNotExist(storageSize);
            log.Info("Virtual drive initialized: {0}",cloudDrive.Uri);

            var mountedDirectoryPath = cloudDrive.Mount(storageSize, DriveMountOptions.None);
            log.Info("Virtual drive mounted at: {0}",mountedDirectoryPath);

            mountedDirectory = new DirectoryInfo(mountedDirectoryPath);

            log.Info("Executing drive benchmark for: {0}",mountedDirectoryPath);
            ExecuteBenchmarks(mountedDirectory,storageSize);
            log.Info("Storage initialization succeeded");
        }
開發者ID:skovborg,項目名稱:RavenDb.Azure,代碼行數:60,代碼來源:CloudStorageProvider.cs

示例15: given_blob_storage

 public given_blob_storage()
 {
     var settings = InfrastructureSettings.Read("Settings.xml").BlobStorage;
     this.account = CloudStorageAccount.Parse(settings.ConnectionString);
     this.rootContainerName = Guid.NewGuid().ToString();
     this.sut = new CloudBlobStorage(account, this.rootContainerName);
 }
開發者ID:TiagoTerra,項目名稱:cqrs-journey,代碼行數:7,代碼來源:CloudBlobStorageFixture.cs


注:本文中的Microsoft.WindowsAzure.CloudStorageAccount類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。