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


C# CloudBlobClient.GetContainerReference方法代碼示例

本文整理匯總了C#中Microsoft.WindowsAzure.StorageClient.CloudBlobClient.GetContainerReference方法的典型用法代碼示例。如果您正苦於以下問題:C# CloudBlobClient.GetContainerReference方法的具體用法?C# CloudBlobClient.GetContainerReference怎麽用?C# CloudBlobClient.GetContainerReference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.WindowsAzure.StorageClient.CloudBlobClient的用法示例。


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

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

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

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

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

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

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

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

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

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

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

示例11: AzureHelper

 static AzureHelper()
 {
     var cloudStorageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=http;AccountName=mintchipmarket;AccountKey=6wtpT0uW75m2LsThfROjp+cMA5zWx8VllZhJ5tM7kPAZZlIbPZ0t7pIXkO0s0AnzZ4sWMnl+rc5+1KjlNWKlfA==");
     var blobClient = new CloudBlobClient(cloudStorageAccount.BlobEndpoint, cloudStorageAccount.Credentials);
     _container = blobClient.GetContainerReference("files");
     _container.CreateIfNotExist();
     _container.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Off });
 }
開發者ID:StevenGilligan,項目名稱:MintChipMarket,代碼行數:8,代碼來源:AzureHelper.cs

示例12: AzureSystemEventStore

 public AzureSystemEventStore()
 {
     Streamer = new EventStreamer(new EventSerializer(MessagesProvider.GetKnownEventTypes()));
     CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Settings.Default.AzureConnectionString);
     blobClient = storageAccount.CreateCloudBlobClient();
     container = blobClient.GetContainerReference(Settings.Default.AzureContainerName);
     container.CreateIfNotExist();
 }
開發者ID:stemarie,項目名稱:CqrsSiteEngine,代碼行數:8,代碼來源:AzureSystemEventStore.cs

示例13: ConnectToBlobStorage

 /// <summary>
 /// Connects to the storage account and creates the default container 
 /// </summary>
 private void ConnectToBlobStorage()
 {
     storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
     blobClient = storageAccount.CreateCloudBlobClient();
     blobContainer = blobClient.GetContainerReference("testcontainer");
     blobContainer.CreateIfNotExist();
     blobContainer.SetPermissions(new BlobContainerPermissions() { PublicAccess = BlobContainerPublicAccessType.Blob });
 }
開發者ID:twopieman,項目名稱:PictureService,代碼行數:11,代碼來源:PictureService.svc.cs

示例14: AzureStorageClient

        public AzureStorageClient(CloudStorageAccount account)
        {
            client = account.CreateCloudBlobClient();
            client.DefaultDelimiter = "/";

            container = client.GetContainerReference("documents");
            container.CreateIfNotExist();
        }
開發者ID:Amichai,項目名稱:Prax,代碼行數:8,代碼來源:AzureStorageClient.cs

示例15: deleteFromBlob

 public void deleteFromBlob(string uri, string blobname)
 {
     CloudStorageAccount storageAccount;
     storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("BlobConnectionString"));
     blobClient = storageAccount.CreateCloudBlobClient();
     blobContainer = blobClient.GetContainerReference(blobname);
     var blob = blobContainer.GetBlobReference(uri);
     blob.DeleteIfExists();
 }
開發者ID:bcary,項目名稱:Vestn_Backend,代碼行數:9,代碼來源:BlobStorageAccessor.cs


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