EN
Bu içerik dilinizde bulunmamaktadır ancak İngilizce sürümüne buradan bakabilirsiniz.

CloudBlobClient.GetBlobReferenceFromServer Method

 

Updated: February 24, 2017

Gets a reference to a blob by making a request to the service.

Namespace:   Microsoft.WindowsAzure.Storage.Blob
Assembly:  Microsoft.WindowsAzure.Storage (in Microsoft.WindowsAzure.Storage.dll)

NameDescription
System_CAPS_pubmethodGetBlobReferenceFromServer(StorageUri, AccessCondition, BlobRequestOptions, OperationContext)

Gets a reference to a blob by making a request to the service.

System_CAPS_pubmethodGetBlobReferenceFromServer(Uri, AccessCondition, BlobRequestOptions, OperationContext)

Gets a reference to a blob by making a request to the service.

Gets a reference to a blob with a request to the server. Contrast this method with other methods that return a reference to a blob, where no call to the server is made.

If the blob does not exist, this call will fail with a 404 error (Not Found).

System_CAPS_noteNote

Microsoft recommends that you call asynchronous methods in your code whenever possible for optimal performance. The recommended methods are those that use the Async/Await pattern. For more information about asynchronous programming in .NET with Async/Await, see Asynchronous Programming with Async and Await (C# and Visual Basic).

The analogous method that uses Async/Await is GetBlobReferenceFromServerAsync.

private static void GetExistingBlobReference(CloudBlobContainer container, string blobName)
{
    try
    {
        // Get a reference to a blob with a request to the server.
        // If the blob does not exist, this call will fail with a 404 (Not Found).
        ICloudBlob blob = container.GetBlobReferenceFromServer(blobName);

        // The previous call gets the blob's properties, so it's not necessary to call FetchAttributes
        // to read a property.
        Console.WriteLine("Blob {0} was last modified at {1} local time.", blobName,
            blob.Properties.LastModified.Value.LocalDateTime);
    }
    catch (StorageException e)
    {
        if (e.RequestInformation.HttpStatusCode == 404)
        {
            Console.WriteLine("Blob {0} does not exist.", blobName);
            Console.WriteLine("Additional error information: " + e.Message);
        }
        else
        {
            Console.WriteLine(e.Message);
            Console.ReadLine();
            throw;
        }
    }

    Console.WriteLine();
}

Return to top
Show: