本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient类的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobClient类的具体用法?C# CloudBlobClient怎么用?C# CloudBlobClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudBlobClient类属于Microsoft.WindowsAzure.Storage.Blob命名空间,在下文中一共展示了CloudBlobClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AzureBlobClient
public AzureBlobClient()
{
var storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
_blobClient = storageAccount.CreateCloudBlobClient();
}
示例2: TestInitialize
public void TestInitialize()
{
this.blobClient = GenerateCloudBlobClient();
// Create and log a new prefix for this test.
this.prefix = Guid.NewGuid().ToString("N");
}
示例3: AzureImageUploader
public AzureImageUploader()
{
var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
_blobClient = storageAccount.CreateCloudBlobClient();
_container = FindOrCreateContainer(ContainerName);
_filecontainer = FindOrCreateContainer(FileContainerName);
}
示例4: UploadBlob
public Task UploadBlob(
Uri url,
string localFile,
FileEncryption fileEncryption,
CancellationToken cancellationToken,
CloudBlobClient client,
IRetryPolicy retryPolicy,
string contentType = null,
string subDirectory = "",
Func<string> getSharedAccessSignature = null,
int parallelTransferThreadCount = 10,
int numberOfConcurrentTransfers = default(int))
{
SetConnectionLimits(url, numberOfConcurrentTransfers);
return Task.Factory.StartNew(
() => UploadFileToBlob(
cancellationToken,
url,
localFile,
contentType,
subDirectory,
fileEncryption,
client,
retryPolicy,
getSharedAccessSignature,
parallelTransferThreadCount),
cancellationToken);
}
示例5: LocationModeWithMissingUriAsync
public async Task LocationModeWithMissingUriAsync()
{
AssertSecondaryEndpoint();
CloudBlobClient client = GenerateCloudBlobClient();
CloudBlobClient primaryOnlyClient = new CloudBlobClient(client.BaseUri, client.Credentials);
CloudBlobContainer container = primaryOnlyClient.GetContainerReference("nonexistingcontainer");
BlobRequestOptions options = new BlobRequestOptions()
{
LocationMode = LocationMode.SecondaryOnly,
RetryPolicy = new NoRetry(),
};
Exception e = await TestHelper.ExpectedExceptionAsync<Exception>(
async () => await container.FetchAttributesAsync(null, options, null),
"Request should fail when an URI is not provided for the target location");
Assert.IsInstanceOfType(e.InnerException, typeof(InvalidOperationException));
options.LocationMode = LocationMode.SecondaryThenPrimary;
e = await TestHelper.ExpectedExceptionAsync<Exception>(
async () => await container.FetchAttributesAsync(null, options, null),
"Request should fail when an URI is not provided for the target location");
Assert.IsInstanceOfType(e.InnerException, typeof(InvalidOperationException));
options.LocationMode = LocationMode.PrimaryThenSecondary;
e = await TestHelper.ExpectedExceptionAsync<Exception>(
async () => await container.FetchAttributesAsync(null, options, null),
"Request should fail when an URI is not provided for the target location");
Assert.IsInstanceOfType(e.InnerException, typeof(InvalidOperationException));
}
示例6: UsersForAdminCsvPublishService
public UsersForAdminCsvPublishService(CloudBlobClient blobClient,
IAdminUserService adminUserService,
IMapper mapper) : base(blobClient, new UserForAdminCsvFormatter())
{
_adminUserService = adminUserService;
_mapper = mapper;
}
示例7: Run
public static void Run(string connectionString, bool disableLogging)
{
_connectionString = connectionString;
_storageAccount = CloudStorageAccount.Parse(connectionString);
_blobClient = _storageAccount.CreateCloudBlobClient();
Console.WriteLine("Creating the test blob...");
CreateTestBlob();
try
{
TimeSpan azureSDKTime = RunAzureSDKTest();
TimeSpan webJobsSDKTime = RunWebJobsSDKTest(disableLogging);
// Convert to ulong because the measurment block does not support other data type
ulong perfRatio = (ulong)((webJobsSDKTime.TotalMilliseconds / azureSDKTime.TotalMilliseconds) * 100);
Console.WriteLine("--- Results ---");
Console.WriteLine("Azure SDK: {0} ms: ", azureSDKTime.TotalMilliseconds);
Console.WriteLine("WebJobs SDK: {0} ms: ", webJobsSDKTime.TotalMilliseconds);
Console.WriteLine("Perf ratio (x100, long): {0}", perfRatio);
MeasurementBlock.Mark(
perfRatio,
(disableLogging ? BlobNoLoggingOverheadMetric : BlobLoggingOverheadMetric) + ";Ratio;Percent");
}
finally
{
Cleanup();
}
}
示例8: FunctionsController
internal FunctionsController(
CloudStorageAccount account,
CloudBlobClient blobClient,
IFunctionInstanceLookup functionInstanceLookup,
IFunctionLookup functionLookup,
IFunctionIndexReader functionIndexReader,
IHeartbeatValidityMonitor heartbeatMonitor,
IAborter aborter,
IRecentInvocationIndexReader recentInvocationsReader,
IRecentInvocationIndexByFunctionReader recentInvocationsByFunctionReader,
IRecentInvocationIndexByJobRunReader recentInvocationsByJobRunReader,
IRecentInvocationIndexByParentReader recentInvocationsByParentReader,
IFunctionStatisticsReader statisticsReader,
ILogReader reader)
{
_account = account;
_blobClient = blobClient;
_functionInstanceLookup = functionInstanceLookup;
_functionLookup = functionLookup;
_functionIndexReader = functionIndexReader;
_heartbeatMonitor = heartbeatMonitor;
_aborter = aborter;
_recentInvocationsReader = recentInvocationsReader;
_recentInvocationsByFunctionReader = recentInvocationsByFunctionReader;
_recentInvocationsByJobRunReader = recentInvocationsByJobRunReader;
_recentInvocationsByParentReader = recentInvocationsByParentReader;
_statisticsReader = statisticsReader;
_reader = reader;
}
示例9: BlobStorageManager
public BlobStorageManager(string blobConnectionEndPointString)
{
this.blobConnectionEndPointString = blobConnectionEndPointString;
CloudStorageAccount VP2ClientBlobStorageAccount = CloudStorageAccount.Parse(blobConnectionEndPointString);
VP2CloudBlobClient = VP2ClientBlobStorageAccount.CreateCloudBlobClient();
VP2CloudTableClient = VP2ClientBlobStorageAccount.CreateCloudTableClient();
}
示例10: Blob
/// <summary>
/// Constructor
/// </summary>
/// <param name="blobClient">use BlobConn to get blobClient</param>
/// <param name="clientContainerName">This should be the ID of the User</param>
/// <returns></returns>
public Blob(CloudBlobClient blobClient, string clientContainerName)
{
//Get a reference to a container and create container for first time use user
container = blobClient.GetContainerReference(clientContainerName);
container.CreateIfNotExists();
indicator = "OK";
}
示例11: BlobStorage
public BlobStorage()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ReadConfig.CommonCloudCoreApplicationSettings.Storage.StorageConnectionString);
blobClient = storageAccount.CreateCloudBlobClient();
blobClient.DefaultRequestOptions.ServerTimeout = TimeSpan.FromMinutes(10);
// blobClient.ServerTimeout = TimeSpan.FromMinutes(10);
}
示例12: BlobFileProvider
public BlobFileProvider(IEnumerable<string> locations)
: base()
{
_storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
_blobClient = _storageAccount.CreateCloudBlobClient();
_container = _blobClient.GetContainerReference("data");
_container.CreateIfNotExists();
_strings = new List<string>();
foreach(string location in locations) {
foreach (IListBlobItem item in _container.ListBlobs(location,true))
{
if (item.GetType() == typeof(CloudBlockBlob))
{
CloudBlockBlob blob = (CloudBlockBlob)item;
string text;
using (var memoryStream = new MemoryStream())
{
blob.DownloadToStream(memoryStream);
text = Encoding.UTF8.GetString(memoryStream.ToArray());
if (text[0] == _byteOrderMarkUtf8[0])
{
text= text.Remove(0,_byteOrderMarkUtf8.Length);
}
_strings.Add(text);
}
}
}
}
}
示例13: UploadBlob
public Task UploadBlob(
Uri url,
string localFile,
FileEncryption fileEncryption,
CancellationToken cancellationToken,
CloudBlobClient client,
IRetryPolicy retryPolicy,
string contentType = null,
string subDirectory = "",
Func<string> getSharedAccessSignature = null)
{
SetConnectionLimits(url);
return Task.Factory.StartNew(
() => UploadFileToBlob(
cancellationToken,
url,
localFile,
contentType,
subDirectory,
fileEncryption,
client,
retryPolicy,
getSharedAccessSignature),
cancellationToken);
}
示例14: AzureDirectory
/// <summary>
/// Create an AzureDirectory
/// </summary>
/// <param name="storageAccount">storage account to use</param>
/// <param name="containerName">name of container (folder in blob storage)</param>
/// <param name="cacheDirectory">local Directory object to use for local cache</param>
/// <param name="rootFolder">path of the root folder inside the container</param>
public AzureDirectory(
CloudStorageAccount storageAccount,
string containerName = null,
Lucene.Net.Store.Directory cacheDirectory = null,
bool compressBlobs = false,
string rootFolder = null)
{
if (storageAccount == null)
throw new ArgumentNullException("storageAccount");
if (string.IsNullOrEmpty(containerName))
_containerName = "lucene";
else
_containerName = containerName.ToLower();
if (string.IsNullOrEmpty(rootFolder))
_rootFolder = string.Empty;
else
{
rootFolder = rootFolder.Trim('/');
_rootFolder = rootFolder + "/";
}
_blobClient = storageAccount.CreateCloudBlobClient();
_initCacheDirectory(cacheDirectory);
this.CompressBlobs = compressBlobs;
}
示例15: UploadFile
public virtual Uri UploadFile(
string storageName,
Uri blobEndpointUri,
string storageKey,
string filePath,
BlobRequestOptions blobRequestOptions)
{
StorageCredentials credentials = new StorageCredentials(storageName, storageKey);
CloudBlobClient client = new CloudBlobClient(blobEndpointUri, credentials);
string blobName = string.Format(
CultureInfo.InvariantCulture,
"{0}_{1}",
DateTime.UtcNow.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture),
Path.GetFileName(filePath));
CloudBlobContainer container = client.GetContainerReference(ContainerName);
container.CreateIfNotExists();
CloudBlockBlob blob = container.GetBlockBlobReference(blobName);
BlobRequestOptions uploadRequestOption = blobRequestOptions ?? new BlobRequestOptions();
if (!uploadRequestOption.ServerTimeout.HasValue)
{
uploadRequestOption.ServerTimeout = TimeSpan.FromMinutes(300);
}
using (FileStream readStream = File.OpenRead(filePath))
{
blob.UploadFromStream(readStream, AccessCondition.GenerateEmptyCondition(), uploadRequestOption);
}
return new Uri(string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}", client.BaseUri, ContainerName, client.DefaultDelimiter, blobName));
}