Question 40 of 179 from exam AZ-204: Developing Solutions for Microsoft Azure

Question 40 of 179 from exam AZ-204: Developing Solutions for Microsoft Azure

Question

HOTSPOT - You are developing a solution that uses the Azure Storage Client library for .NET.

You have the following code: (Line numbers are included for reference only.)

01 CloudBlockBlob sre = null;

02 try

03 {

04 src container.ListBlobs() .Offype<CloudBlockBlob>() .FirstOrDefault ();
05 var id = await src.AcquireLeaseAsync (null);

06 var dst container .GetBlockBlobReference (src.Name) ;

07 string cpid = await dst.StartCopyAsync (src) ;
08 await dst.FetchattributeAsync();

03 = return id;

10}

11 catch (Exception e)
12 {

13 throw;

14}

15 finally

16 {

17 if (sre null)

18 await sre.FetchAttributesAsync();

19 if (src.Properties.LeaseState != LeaseState.Available)
20 await src.BreakLeaseAsync(new TimeSpan(0));

21}

For each of the following statements, select Yes if the statement is true.

Otherwise, select No.

NOTE: Each correct selection is worth one point.

Hot Area:

Answer Area

Statement

The code creates an infinite lease

The code at line 06 always creates a new blob

The finally block releases the lease

Yes

No

Explanations

Answer Area

Statement

The code creates an infinite lease

The code at line 06 always creates a new blob

The finally block releases the lease

Yes

No

Box 1: Yes - AcquireLeaseAsync does not specify leaseTime.

leaseTime is a TimeSpan representing the span of time for which to acquire the lease, which will be rounded down to seconds.

If null, an infinite lease will be acquired.

If not null, this must be 15 to 60 seconds.

Box 2: No - The GetBlockBlobReference method just gets a reference to a block blob in this container.

Box 3: Yes - The BreakLeaseAsync method initiates an asynchronous operation that breaks the current lease on this container.

https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.storage.blob.cloudblobcontainer.acquireleaseasync https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.storage.blob.cloudblobcontainer.getblockblobreference https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.storage.blob.cloudblobcontainer.breakleaseasync