• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# StorageClient.CloudBlobClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Initialize

        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);

            DataServiceContext context =
                new DataServiceContext(CloudStorageAccount.DevelopmentStorageAccount.TableEndpoint.AbsoluteUri,
                    CloudStorageAccount.DevelopmentStorageAccount.Credentials);

            CloudBlobClient blobClient = new CloudBlobClient(CloudStorageAccount.DevelopmentStorageAccount.BlobEndpoint.AbsoluteUri,
                CloudStorageAccount.DevelopmentStorageAccount.Credentials);

            Services = new ServiceFacade();

            Services.Accounts = new AccountService(Services, new AccountServiceImplementor(context));
            Services.Groups = new GroupService(Services, new GroupServiceImplementor(context));
            Services.Roles = new RoleService(Services, new RoleServiceImplementor(context));
            Services.Images = new ImageService(Services, new ImageServiceImplementor(context));
            Services.Blobs = new BlobService(Services, new BlobServiceImplementor(blobClient));

            if (User.Identity.IsAuthenticated)
                Account = Services.Accounts.Get(User.Identity.Name);
            else
                Account = null;

            if (null == Account)
                FormsAuthentication.SignOut();
            else
            {
                Account.LastActivityDate = DateTime.Now;
                Account.Save();
            }

            ViewData["Account"] = Account;
        }
开发者ID:retran,项目名称:old-projects-backup,代码行数:34,代码来源:BaseController.cs


示例2: AzureOperations

 public AzureOperations(string connectionString)
 {
     CloudStorageAccount account = CloudStorageAccount.Parse(connectionString);
     client = account.CreateCloudBlobClient();
     var container = client.GetContainerReference("$root");
     container.CreateIfNotExist();
 }
开发者ID:richorama,项目名称:AzureBlobDrive,代码行数:7,代码来源:AzureOperations.cs


示例3: AzureBlobClient

 public AzureBlobClient(Uri endpoint, string accountName, string accountKey, int timeoutInMinutes = 30, int parallelOperationThreadCount = 1)
 {
     var credentials = new StorageCredentialsAccountAndKey(accountName, accountKey);
     blobClient = new CloudBlobClient(endpoint, credentials);
     blobClient.Timeout = new TimeSpan(0, timeoutInMinutes, 0);
     blobClient.ParallelOperationThreadCount = parallelOperationThreadCount;
 }
开发者ID:cbertolasio,项目名称:Windows.Azure.Msbuild,代码行数:7,代码来源:AzureBlobClient.cs


示例4: OnStart

        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;
            #if DEBUG
            account = CloudStorageAccount.DevelopmentStorageAccount;
            #else
            account = new CloudStorageAccount(accountAndKey, true);
            #endif

            tableContext = new TableServiceContext(account.TableEndpoint.ToString(), account.Credentials);

            //client = new CloudQueueClient(account.BlobEndpoint.ToString(), account.Credentials);
            qclient = account.CreateCloudQueueClient();
            q = qclient.GetQueueReference("icd9mapplotrequests");
            rows = new List<ICD9MapPlotResultEntry>();
            bclient = account.CreateCloudBlobClient();
            container = bclient.GetContainerReference("results");
            container.CreateIfNotExist();
            client = account.CreateCloudTableClient();
            client.CreateTableIfNotExist("ICD9MapPlotResult");
            client.CreateTableIfNotExist("DoctorDetails");
            client.CreateTableIfNotExist("PatientDetails");
            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            return base.OnStart();
        }
开发者ID:cloudscrubs,项目名称:azureprototype,代码行数:28,代码来源:WorkerRole.cs


示例5: MyClassInitialize

 public static void MyClassInitialize(TestContext testContext)
 {
     CloudStorageAccount storageAccount = CloudStorageAccount.Parse(DevConnectionString);
     blobClient = storageAccount.CreateCloudBlobClient();
     container = blobClient.GetContainerReference(TestContainerName);
     container.CreateIfNotExist();
 }
开发者ID:phillipknauss,项目名称:CqrsSiteEngine,代码行数:7,代码来源:AzureTapeStreamTest.cs


示例6: LargeDataExample

 public LargeDataExample(String queueName)
 {
     CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["DataConnectionString"]);
     CloudQueueClient cloudQueueClient = cloudStorageAccount.CreateCloudQueueClient();
     cloudQueue = cloudQueueClient.GetQueueReference(queueName);
     cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
 }
开发者ID:yoshiao,项目名称:Azure_Parallel_Samples,代码行数:7,代码来源:LargeDataExample.cs


示例7: OnStart

        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 100;

            //Initialize Indexer
            storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("CrawlerStorage"));

            //Initialize URL Queue
            urlQueueClient = storageAccount.CreateCloudQueueClient();
            urlQueue = urlQueueClient.GetQueueReference("urlqueue");
            if (urlQueue.CreateIfNotExist())
            {
                //Add first URL to the queue
                CloudQueueMessage firstURL = new CloudQueueMessage(startURL);
                urlQueue.AddMessage(firstURL);
            }

            //Initialize Index Queue
            indexQueueClient = storageAccount.CreateCloudQueueClient();
            indexQueue = indexQueueClient.GetQueueReference("indexqueue");
            indexQueue.CreateIfNotExist();

            //Initialize Database Blob
            databaseClient = storageAccount.CreateCloudBlobClient();
            databaseContainer = databaseClient.GetContainerReference("wordfrequencies");
            databaseContainer.CreateIfNotExist();
            var permission = databaseContainer.GetPermissions();
            permission.PublicAccess = BlobContainerPublicAccessType.Container;
            databaseContainer.SetPermissions(permission);

            return base.OnStart();
        }
开发者ID:nicolas3470,项目名称:Distributed-Web-Crawler,代码行数:33,代码来源:WorkerRole.cs


示例8: SharedAccessSignatureController

        public SharedAccessSignatureController(CloudStorageAccount storageAccount)
        {
            if (storageAccount == null)
                throw new ArgumentNullException("storageAccount", Constants.CloudStorageAccountNullArgumentErrorMessage);

            this.cloudBlobClient = storageAccount.CreateCloudBlobClient();
        }
开发者ID:wadewegner,项目名称:TechEd_NZAU,代码行数:7,代码来源:SharedAccessSignatureController.cs


示例9: AzureStorageProvider

        public AzureStorageProvider(CloudStorageAccount storageAccount)
        {
            cloudStorageAccount = storageAccount;

            // Create the blob client
            blobStorage = cloudStorageAccount.CreateCloudBlobClient();
        }
开发者ID:CloudMorph,项目名称:CloudMorph,代码行数:7,代码来源:AzureStorageProvider.cs


示例10: BlobHelper

    // Constructor - pass in a storage connection string.
    public BlobHelper(string connectionString)
    {
        Account = CloudStorageAccount.Parse(connectionString);

            BlobClient = Account.CreateCloudBlobClient();
            BlobClient.RetryPolicy = RetryPolicies.Retry(4, TimeSpan.Zero);
    }
开发者ID:colebank,项目名称:BloodHound,代码行数:8,代码来源:BlobHelper.cs


示例11: GetBlobPath

        private static string GetBlobPath(HttpRequest request)
        {
            string hostName = request.Url.DnsSafeHost;
            if (hostName == "localdev")
            {
                hostName = "www.protonit.net";
            }
            string containerName = hostName.Replace('.', '-');
            string currServingFolder = "";
            try
            {
                // "/2013-03-20_08-27-28";
                CloudBlobClient publicClient = new CloudBlobClient("http://caloom.blob.core.windows.net/");
                string currServingPath = containerName + "/" + RenderWebSupport.CurrentToServeFileName;
                var currBlob = publicClient.GetBlockBlobReference(currServingPath);
                string currServingData = currBlob.DownloadText();
                string[] currServeArr = currServingData.Split(':');
                string currActiveFolder = currServeArr[0];
                var currOwner = VirtualOwner.FigureOwner(currServeArr[1]);
                InformationContext.Current.Owner = currOwner;
                currServingFolder = "/" + currActiveFolder;
            }
            catch
            {

            }
            return containerName + currServingFolder + request.Path;
        }
开发者ID:kallex,项目名称:Caloom,代码行数:28,代码来源:AnonymousBlobStorageHandler.cs


示例12: BlobEntities

        public BlobEntities()
        {
            if (storageInitialized)
            {
                return;
            }

            lock (gate)
            {
                if (storageInitialized)
                {
                    return;
                }
                    // read account configuration settings
                    var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

                    // create blob container for images
                    blobStorage = storageAccount.CreateCloudBlobClient();
                    CloudBlobContainer container = blobStorage.GetContainerReference("productimages");
                    container.CreateIfNotExist();

                    // configure container for public access
                    var permissions = container.GetPermissions();
                    permissions.PublicAccess = BlobContainerPublicAccessType.Container;
                    container.SetPermissions(permissions);

                storageInitialized = true;
            }
        }
开发者ID:akandrei,项目名称:mK,代码行数:29,代码来源:BlobEntities.cs


示例13: 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


示例14: UploadFile

        public static Uri UploadFile(string storageName, string storageKey, string filePath)
        {
            var baseAddress = string.Format(CultureInfo.InvariantCulture, ConfigurationConstants.BlobEndpointTemplate, storageName);
            var credentials = new StorageCredentialsAccountAndKey(storageName, storageKey);
            var client = new CloudBlobClient(baseAddress, credentials);

            string containerName = "mydeployments";
            string blobName = string.Format(
                CultureInfo.InvariantCulture,
                "{0}_{1}",
                DateTime.UtcNow.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture),
                Path.GetFileName(filePath));

            CloudBlobContainer container = client.GetContainerReference(containerName);
            container.CreateIfNotExist();
            CloudBlob blob = container.GetBlobReference(blobName);

            // blob.UploadFile(filePath);
            UploadBlobStream(blob, filePath);

            return new Uri(
                string.Format(
                    CultureInfo.InvariantCulture,
                    "{0}{1}{2}{3}",
                    client.BaseUri,
                    containerName,
                    client.DefaultDelimiter,
                    blobName));
        }
开发者ID:chandermani,项目名称:deployToAzureTFS2013,代码行数:29,代码来源:AzureBlob.cs


示例15: WorkerRoleLoader

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

            this.storageAccount = CloudStorageAccount.FromConfigurationSetting(DataConfigurationKey);
            this.blobStorage = storageAccount.CreateCloudBlobClient();
        }
开发者ID:southworks,项目名称:workerroleaccelerator,代码行数:7,代码来源:WorkerRoleLoader.cs


示例16: InsertBlobUrlHelper

        //Allows other server code to use the InsertBlobUrl logic.
        //Maximum blob size is 32mb.
        internal static Task<string> InsertBlobUrlHelper(Guid ownerPartyId, Guid fileGuid)
        {
            return AsyncHelper.RunAsync(() =>
            {
                //Create service client for credentialed access to the Blob service.
                var blobClient = new CloudBlobClient(AzureServerHelpers.BlobStorageUrl,
                    new StorageCredentialsAccountAndKey(AzureServerHelpers.AccountName, AzureServerHelpers.AccountKey)) { Timeout = TimeSpan.FromMilliseconds(TimeoutMilliseconds) };

                //Get a reference to a container, which may or may not exist.
                var blobContainer = blobClient.GetContainerReference(AzureServerHelpers.BuildContainerUrl(ownerPartyId));
                //Create a new container, if it does not exist
                blobContainer.CreateIfNotExist(new BlobRequestOptions { Timeout = TimeSpan.FromMilliseconds(TimeoutMilliseconds) });

                //Setup cross domain policy so Silverlight can access the server
                CreateSilverlightPolicy(blobClient);

                //Get a reference to a blob, which may or may not exist.
                var blob = blobContainer.GetBlobReference(fileGuid.ToString());

                blob.UploadByteArray(new byte[] { });

                // Set the metadata into the blob
                blob.Metadata["Submitter"] = ownerPartyId.ToString();
                blob.SetMetadata();

                // Set the properties
                blob.Properties.ContentType = "application/octet-stream";
                blob.SetProperties();

                return blob.GetSharedAccessSignature(new SharedAccessPolicy { Permissions = SharedAccessPermissions.Write, SharedAccessExpiryTime = DateTime.UtcNow + new TimeSpan(0, 30, 0) });
            });
        }
开发者ID:FoundOPS,项目名称:server,代码行数:34,代码来源:FileController.cs


示例17: GetSharedAccessSignatureHashImpl

        /// <summary>
        /// Get the signature hash embedded inside the Shared Access Signature.
        /// </summary>
        /// <param name="policy">The shared access policy to hash.</param>
        /// <param name="groupPolicyIdentifier">An optional identifier for the policy.</param>
        /// <param name="resourceName">The canonical resource string, unescaped.</param>
        /// <param name="client">The client whose credentials are to be used for signing.</param>
        /// <returns>The signed hash.</returns>
        internal static string GetSharedAccessSignatureHashImpl(
            SharedAccessPolicy policy,
            string groupPolicyIdentifier,
            string resourceName,
            CloudBlobClient client)
        {
            CommonUtils.AssertNotNull("policy", policy);
            CommonUtils.AssertNotNullOrEmpty("resourceName", resourceName);
            CommonUtils.AssertNotNull("client", client);

            ////StringToSign = signedpermissions + "\n"
            ////               signedstart + "\n"
            ////               signedexpiry + "\n"
            ////               canonicalizedresource + "\n"
            ////               signedidentifier
            ////HMAC-SHA256(URL.Decode(UTF8.Encode(StringToSign)))

            string stringToSign = string.Format(
                "{0}\n{1}\n{2}\n{3}\n{4}",
                SharedAccessPolicy.PermissionsToString(policy.Permissions),
                GetDateTimeOrEmpty(policy.SharedAccessStartTime),
                GetDateTimeOrEmpty(policy.SharedAccessExpiryTime),
                resourceName,
                groupPolicyIdentifier);

            string signature = client.Credentials.ComputeHmac(stringToSign);

            return signature;
        }
开发者ID:nagyist,项目名称:azure-sdk-for-mono,代码行数:37,代码来源:SharedAccessSignatureHelper.cs


示例18: 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


示例19: 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


示例20: AzureExecute

        /// <summary>
        /// Connect to an Azure subscription and upload a package to blob storage.
        /// </summary>
        protected override void AzureExecute()
        {
            string storageKey = this.StorageKeys.Get(this.ActivityContext).Primary;
            string storageName = this.StorageServiceName.Get(this.ActivityContext);
            string filePath = this.LocalPackagePath.Get(this.ActivityContext);

            var baseAddress = string.Format(CultureInfo.InvariantCulture, ConfigurationConstants.BlobEndpointTemplate, storageName);
            var credentials = new StorageCredentialsAccountAndKey(storageName, storageKey);
            var client = new CloudBlobClient(baseAddress, credentials);

            const string ContainerName = "mydeployments";
            string blobName = string.Format(
                CultureInfo.InvariantCulture,
                "{0}_{1}",
                DateTime.UtcNow.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture),
                Path.GetFileName(filePath));

            CloudBlobContainer container = client.GetContainerReference(ContainerName);
            container.CreateIfNotExist();
            CloudBlob blob = container.GetBlobReference(blobName);

            UploadBlobStream(blob, filePath);

            this.PackageUrl.Set(this.ActivityContext, string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}", client.BaseUri, ContainerName, client.DefaultDelimiter, blobName));
        }
开发者ID:modulexcite,项目名称:CustomActivities,代码行数:28,代码来源:UploadPackageToBlobStorage.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# StorageClient.CloudBlobContainer类代码示例发布时间:2022-05-26
下一篇:
C# StorageClient.CloudBlob类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap