当前位置: 首页>>代码示例>>C#>>正文


C# CloudStorageAccount类代码示例

本文整理汇总了C#中CloudStorageAccount的典型用法代码示例。如果您正苦于以下问题:C# CloudStorageAccount类的具体用法?C# CloudStorageAccount怎么用?C# CloudStorageAccount使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CloudStorageAccount类属于命名空间,在下文中一共展示了CloudStorageAccount类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NDIAzureTableController

 static NDIAzureTableController()
 {
     _storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
     _tableClient = _storageAccount.CreateCloudTableClient();
     _table = _tableClient.GetTableReference("ndiparams");
     _retrieveOperation = TableOperation.Retrieve("VidParams", "LastVideo");
 }
开发者ID:JuanKRuiz,项目名称:Noches-de-Innovacion-Website,代码行数:7,代码来源:NDIAzureTableController.cs

示例2: TProduct

        public TProduct(string affiliate, string code, int qty, bool force_lookup = false)
        {
            ProductCode = code;
            Qty = qty;

            cloud = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("AbundaStorage"));

            client = cloud.CreateCloudTableClient();

            products = client.GetTableReference("Products");
            products.CreateIfNotExists();

            using (var context = new DataBaseDataContext())
            {
                var aff = (from ev in context.Affiliates
                           where ev.code == affiliate
                           select ev).FirstOrDefault();

                merchantID = aff.MerchantID;
                marketplaceID = aff.MarketPlaceID;
                secretKey = aff.SecretKey;
                accessKey = aff.AccessKey;
            }

            var amzResults = PerformAmazonLookup();
        }
开发者ID:WickedMonkeySoftware,项目名称:AbundaAzure,代码行数:26,代码来源:TProduct.cs

示例3: TableStorageOperations

 public TableStorageOperations()
 {
     //var cloudStorageConnectionString =
     //    CloudConfigurationManager.GetSetting(CloudConfigurationName.DefaultStorageConnectionString);
     var cloudStorageConnectionString =
         ConfigurationManager.ConnectionStrings[CloudConfigurationName.DefaultStorageConnectionString].ConnectionString;
     _cloudStorageAccount = CloudStorageAccount.Parse(cloudStorageConnectionString);
开发者ID:nchetan,项目名称:poc,代码行数:7,代码来源:TableStorageOperations.cs

示例4: Upload

        public Uri Upload(SubscriptionCloudCredentials credentials, string storageAccountName, string packageFile, string uploadedFileName)
        {
            var cloudStorage =
                new CloudStorageAccount(new StorageCredentials(storageAccountName, GetStorageAccountPrimaryKey(credentials, storageAccountName)), true);

            var blobClient = cloudStorage.CreateCloudBlobClient();
            var container = blobClient.GetContainerReference(OctopusPackagesContainerName);
            container.CreateIfNotExists();

            var permission = container.GetPermissions();
            permission.PublicAccess = BlobContainerPublicAccessType.Off;
            container.SetPermissions(permission);

            var fileInfo = new FileInfo(packageFile);

            var packageBlob = GetUniqueBlobName(uploadedFileName, fileInfo, container);
            if (packageBlob.Exists())
            {
                Log.VerboseFormat("A blob named {0} already exists with the same length, so it will be used instead of uploading the new package.",
                    packageBlob.Name);
                return packageBlob.Uri;
            }

            UploadBlobInChunks(fileInfo, packageBlob, blobClient);

            Log.Info("Package upload complete");
            return packageBlob.Uri;
        }
开发者ID:bjewell52,项目名称:Calamari,代码行数:28,代码来源:AzurePackageUploader.cs

示例5: Initialise

        /// <summary>
        /// Occurs when a storage provider operation has completed.
        /// </summary>
        //public event EventHandler<StorageProviderEventArgs> StorageProviderOperationCompleted;

        #endregion

        // Initialiser method
        private void Initialise(string storageAccount, string containerName)
        {
            if (String.IsNullOrEmpty(containerName))
                throw new ArgumentException("You must provide the base Container Name", "containerName");
            
            ContainerName = containerName;

            _account = CloudStorageAccount.Parse(storageAccount);
            _blobClient = _account.CreateCloudBlobClient();
            _container = _blobClient.GetContainerReference(ContainerName);
            try
            {
                _container.FetchAttributes();
            }
            catch (StorageException)
            {
                Trace.WriteLine(string.Format("Create new container: {0}", ContainerName), "Information");
                _container.Create();

                // set new container's permissions
                // Create a permission policy to set the public access setting for the container. 
                BlobContainerPermissions containerPermissions = new BlobContainerPermissions();

                // The public access setting explicitly specifies that the container is private,
                // so that it can't be accessed anonymously.
                containerPermissions.PublicAccess = BlobContainerPublicAccessType.Off;

                //Set the permission policy on the container.
                _container.SetPermissions(containerPermissions);
            }
        }
开发者ID:Cache22,项目名称:wedge,代码行数:39,代码来源:AzureBlobStorageProvider.cs

示例6: InitializeCors

        private void InitializeCors()
        {
            var tableServiceProperties = new ServiceProperties();
            var tableClient =
                new CloudStorageAccount(
                    new StorageCredentials(
                        CloudConfigurationManager.GetSetting("storageAccountName"),
                        CloudConfigurationManager.GetSetting("storageAccountKey")),
                    true).CreateCloudTableClient();

            tableServiceProperties.HourMetrics = null;
            tableServiceProperties.MinuteMetrics = null;
            tableServiceProperties.Logging = null;

            tableServiceProperties.Cors = new CorsProperties();
            tableServiceProperties.Cors.CorsRules.Add(new CorsRule()
            {
                AllowedHeaders = new List<string>() { "*" },
                AllowedMethods =  CorsHttpMethods.Get | CorsHttpMethods.Head ,
                //AllowedOrigins = new List<string>() { "http://ercenkbike.azurewebsites.net/" },
                AllowedOrigins = new List<string>() { "*" },
                ExposedHeaders = new List<string>() { "*" },
                MaxAgeInSeconds = 1800 // 30 minutes
            });

            tableClient.SetServiceProperties(tableServiceProperties);
        }
开发者ID:morefun0302,项目名称:BikeTracker,代码行数:27,代码来源:Global.asax.cs

示例7: Initialize

 protected override void Initialize(HttpControllerContext controllerContext)
 {
     base.Initialize(controllerContext);
     storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");
     var tableClient = storageAccount.CreateCloudTableClient();
     table = tableClient.GetTableReference("people");
 }
开发者ID:cmpcdaly,项目名称:table-storage-web-api-cache,代码行数:7,代码来源:PersonController.cs

示例8: CreateCloudStorageContainer

        public CloudStorageContainer CreateCloudStorageContainer(CloudStorageAccount account, Guid publicKey, string alias, string containerName, string description)
        {
            if (account == null)
                throw new NullReferenceException("DefaultCloudStorageAccount cannot be null.");

            Microsoft.WindowsAzure.Storage.CloudStorageAccount storageAccount = CreateInternalAzureCloudStorageAccount(account.AccountName, account.AccountKey);
            Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
            Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer container = blobClient.GetContainerReference(containerName);

            container.Create();

            container.SetPermissions(new Microsoft.WindowsAzure.Storage.Blob.BlobContainerPermissions {
                PublicAccess = Microsoft.WindowsAzure.Storage.Blob.BlobContainerPublicAccessType.Off
            });

            // var containers = blobClient.ListContainers();

            CloudStorageContainer csContainer = this.context.CloudStorageContainers.Add( new CloudStorageContainer {
                CloudStorageAccountId = account.CloudStorageAccountId,
                PublicKey = publicKey,
                ProviderKey = containerName,
                ContainerName = containerName,
                Alias = alias,
                Description = description
            });

            context.SaveChanges();

            return csContainer;
        }
开发者ID:thorvictor,项目名称:SistrategiaDrive,代码行数:30,代码来源:AzureCloudStorageProvider.cs

示例9: DeleteBlob

    public static bool DeleteBlob(string blobName)
    {
        //http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/#delete-blobs

        string accountKey = "",
               accountName = "",
               blobContainer = "";
        try
        {
            CloudStorageAccount storageAccount = new CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(accountName, accountKey), true);

            // Create the blob client.
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            // Retrieve reference to a previously created container.
            CloudBlobContainer container = blobClient.GetContainerReference(blobContainer);

            // Retrieve reference to a blob named "myblob.txt".
            CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName);

            // Delete the blob.
            blockBlob.Delete();
        }
        catch (Exception)
        {
            return false;
        }
        return true;
    }
开发者ID:StouraCH,项目名称:telerik-radcontrols,代码行数:29,代码来源:Default.aspx.cs

示例10: 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:rogierpennink,项目名称:lokad-cloud-storage,代码行数:7,代码来源:AzureStorageModule.cs

示例11: GetCurrentStorageAccount

        public CloudStorageAccount GetCurrentStorageAccount(IServiceManagement channel)
        {
            if (String.IsNullOrEmpty(CurrentStorageAccount))
            {
                return null;
            }

            if (_currentStorageAccount != null)
            {
                return _currentStorageAccount;
            }

            CloudStorageAccount currentStorage = null;
            using (new OperationContextScope((IContextChannel)channel))
            {
                var storageService = channel.GetStorageService(SubscriptionId, CurrentStorageAccount);
                var storageServiceKeys = channel.GetStorageKeys(SubscriptionId, CurrentStorageAccount);
                if (storageService != null && storageServiceKeys != null)
                {
                    string connectionString = General.BuildConnectionString("https", storageService.ServiceName, storageServiceKeys.StorageServiceKeys.Primary, storageService.StorageServiceProperties.Endpoints[0].Replace("http://", "https://"), storageService.StorageServiceProperties.Endpoints[2].Replace("http://", "https://"), storageService.StorageServiceProperties.Endpoints[1].Replace("http://", "https://"));
                    currentStorage = CloudStorageAccount.Parse(connectionString);
                }
            }

            _currentStorageAccount = currentStorage;
            return currentStorage;
        }
开发者ID:nickchal,项目名称:pash,代码行数:27,代码来源:SubscriptionData.cs

示例12: PurgeAllAsync

		/// <summary>
		/// A helper method that purges all of blob storage.
		/// </summary>
		/// <param name="azureAccount">The Azure account to clear out.</param>
		/// <returns>A task representing the asynchronous operation.</returns>
		private static async Task PurgeAllAsync(CloudStorageAccount azureAccount) {
			Requires.NotNull(azureAccount, "azureAccount");

			var blobClient = azureAccount.CreateCloudBlobClient();
			foreach (var container in blobClient.ListContainers()) {
				if (container.Name != "wad-control-container") {
					Console.WriteLine("\nContainer: {0}", container.Name);
					if (container.Name.StartsWith("unittests")) {
						container.Delete();
					} else {
						var blobs = await container.ListBlobsSegmentedAsync(
							container.Name,
							useFlatBlobListing: true,
							pageSize: 50,
							details: BlobListingDetails.Metadata,
							options: new BlobRequestOptions(),
							operationContext: null);
						foreach (var blob in blobs.Cast<ICloudBlob>()) {
							Console.WriteLine("\tBlob: {0} {1}", blob.Uri, blob.Metadata["DeleteAfter"]);
						}

						await Task.WhenAll(blobs.Cast<ICloudBlob>().Select(b => b.DeleteAsync()));
					}
				}
			}
		}
开发者ID:raam030,项目名称:IronPigeon,代码行数:31,代码来源:Program.cs

示例13: MakeQueue

		private static CloudQueue MakeQueue(CloudStorageAccount account)
		{
			var client = account.CreateCloudQueueClient();
			client.RetryPolicy = new ExponentialRetry(new TimeSpan(0, 0, 0, 2), 10);

			return client.GetQueueReference(QueueName);
		}
开发者ID:random-username,项目名称:WindowsAzure.Unity.Demo,代码行数:7,代码来源:QueueMessageSource.cs

示例14: SensorAccess

 public SensorAccess()
 {
     credentials = new StorageCredentials(_accountName, _key);
     storageAccount = new CloudStorageAccount(credentials, true);
     tableClient = storageAccount.CreateCloudTableClient();
     table = tableClient.GetTableReference("AccelerometerTable");
 }
开发者ID:shijiong,项目名称:FallDetection,代码行数:7,代码来源:StorageSensor.cs

示例15: TableStorageAppender

 /// <summary>
 /// Constructs a new instance of the TableStorageAppender with default settings.
 /// </summary>
 /// <param name="storageAccount">The storage account to use</param>
 public TableStorageAppender(CloudStorageAccount storageAccount)
 {
     StorageAccount = storageAccount;
     TableName = "WADLogsTable";
     TransferIntervalInMinutes = 5;
     LogmarkerIntervalInMinutes = 30;
 }
开发者ID:rajeshgupthar,项目名称:Ms.Azure.Logging,代码行数:11,代码来源:TableStorageAppender.cs


注:本文中的CloudStorageAccount类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。