exam questions

Exam AZ-204 All Questions

View all questions & answers for the AZ-204 exam

Exam AZ-204 topic 3 question 1 discussion

Actual exam question from Microsoft's AZ-204
Question #: 1
Topic #: 3
[All AZ-204 Questions]

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.)

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:

Show Suggested Answer Hide Answer
Suggested Answer:
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.
Reference:
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

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Tealon
Highly Voted 4 years, 4 months ago
I think the answer is correct: Optional. Version 2012-02-12 and newer. For a break operation, this is the proposed duration of seconds that the lease should continue before it is broken, between 0 and 60 seconds. This break period is only used if it is shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease will not be available before the break period has expired, but the lease may be held for longer than the break period. If this header does not appear with a break operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks immediately. From: https://docs.microsoft.com/en-us/rest/api/storageservices/lease-blob
upvoted 47 times
AzureFailure
3 years, 10 months ago
It talks about the header values only ReleaseLeaseasync release lease
upvoted 3 times
...
AzureAz204Fan
3 years, 11 months ago
Last few words "infinite lease breaks immediately" is the key for this context.
upvoted 4 times
...
...
Figa
Highly Voted 4 years, 5 months ago
I think Box 3 should be no insetad of yes. BreakRelease don`t release the lease directly. You use ReleaseLease to do this: https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.storage.blob.cloudblobcontainer.releaselease?view=azure-dotnet-legacy
upvoted 24 times
Figa
4 years, 5 months ago
Ah I think modele is right: BreakLeaseAsync (TimeSpan? breakPeriod) breakPeriod Nullable<TimeSpan> A TimeSpan representing the amount of time to allow the lease to remain, which will be rounded down to seconds. If null, the break period is the remainder of the current lease, or zero for infinite leases.
upvoted 4 times
Chang401
2 years, 5 months ago
ya!!! an infinite lease breaks immediately
upvoted 1 times
...
...
...
wafa_chaari
Most Recent 3 months ago
correct . yes no yes - acquire leaseasync(null)--> infinite , On line 6 it gets a reference to a block blob in this container. A lease is a lock on a blob or file for write and delete operations12. The lock duration can be 15 to 60 seconds, or can be infinite
upvoted 1 times
...
4bd3116
7 months, 2 weeks ago
The code creates an infinite lease: The AcquireLeaseAsync method is called with null as the parameter, which does not create an infinite lease. To create an infinite lease, it should be called with -1. Answer: No The code at line 06 always creates a new blob: Line 06 (var dst = container.GetBlockBlobReference(src.Name);) gets a reference to an existing blob with the same name as src. It does not create a new blob but rather references an existing one. Answer: No The finally block releases the lease: The finally block contains await src.BreakLeaseAsync(new TimeSpan(0));, which releases the lease on the blob. Answer: Yes Thanks for pointing that out! Is there anything else you’d like to discuss or clarify?
upvoted 4 times
...
4bd3116
8 months ago
Lease Duration: No, the code does not create an infinite lease. The lease acquired at line 5 (await src.AcquireLeaseAsync(null)) does not specify a duration (the null argument). By default, this results in a finite lease. If you want to create an infinite lease, you can provide a non-null TimeSpan argument to AcquireLeaseAsync, specifying the desired lease duration. Creating a New Blob: No, the code at line 6 (var dst = container.GetBlockBlobReference(src.Name);) does not always create a new blob. Instead, it creates a new CloudBlockBlob reference named dst that points to the same blob as src. Essentially, dst refers to the blob with the same name as src. Releasing the Lease: Yes, the final code ensures that the lease is released. In the finally block (lines 15-25), it checks if src is not null: Fetches attributes of src. If the lease state of src is not available (meaning it’s still leased), it breaks the lease using src.BreakLeaseAsync(new TimeSpan(0)).
upvoted 1 times
...
CafeLago
8 months, 2 weeks ago
Finally block doesn't release the lease. Is nobody else able to see the if above the BreakLeaseAsync?
upvoted 1 times
CafeLago
8 months, 2 weeks ago
Sorry, take it back. LeaseState.Available means not LeaseState.Leased, so not Available means Leased, and so the lease can be broken.
upvoted 2 times
...
...
jobolesonihal
1 year, 1 month ago
Answer is Correct. BlobLease.BreakLeaseAsync: If the break period is not specified, the default value is 0 (immediate break).
upvoted 1 times
...
bgbgvfvf
1 year, 4 months ago
I think the answer is correct
upvoted 2 times
...
dom271219
1 year, 7 months ago
So, when you provide a TimeSpan value of 0, it essentially means "break the lease right now without any delay." This behavior aligns with the statement you provided: "If null, the break period is the remainder of the current lease, or zero for infinite leases." When you explicitly set it to 0, it ensures an immediate lease termination. It is a matter of knowing the English Language.
upvoted 2 times
...
kabbas
1 year, 9 months ago
to break the lease it will have to enter in the if block ..and since the lease ¡state will be always be available since it is infinite ...it will never enter that block...so the answer is no
upvoted 1 times
...
Esward
2 years, 3 months ago
Yes, No, Yes
upvoted 1 times
Esward
2 years, 3 months ago
AcquireLease(null)-->Creates infinite lease
upvoted 2 times
Esward
2 years, 3 months ago
AcquireLease(-1) will also create infinite lease
upvoted 1 times
...
...
...
coffecold
2 years, 6 months ago
version 11 is legacy. Similar code for version 12 see https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-copy?tabs=dotnet
upvoted 1 times
...
coffecold
2 years, 6 months ago
This is Microsoft.Azure.Storage.Blob v11.1.0 code, it is a legacy library. Did anyone got this on the exam recently?
upvoted 2 times
...
strongmmc
2 years, 7 months ago
i'm looking for an explanation on what a "lease" is, or what is intended by it, and cannot find any explanatory resource. Does anyone have a reference to it ?
upvoted 3 times
strongmmc
2 years, 7 months ago
https://www.c-sharpcorner.com/article/implementing-blob-leasing-understanding-blob-storage-part-9/ The Lease Blob operation establishes and manages a lock on a blob for write and delete operations. The lock duration can be 15 to 60 seconds or it can be infinite. Once you have the lease, you can update the Blob or delete the Blob without worrying about another process changing it underneath you. When a Blob is leased, other processes can still read it but any attempt to update it will fail. You can also update Blobs without taking a lease first, but you do run the chance of another process also attempting to modify it at the same time.
upvoted 4 times
...
...
winston_45
2 years, 8 months ago
Correct answer: YES NO YES
upvoted 3 times
...
gds03
2 years, 8 months ago
If the finally code releases the lease, then 1st is wrong. The code doesn't create an infinite lease. Answer is NO.
upvoted 4 times
Emil_Topics
1 year, 5 months ago
I agree. It's a bit silly to create a lease and then removing it, but that is in my opinion what is happing here. Why do people agree that the first one should be YES?
upvoted 1 times
...
...
sasha_gud
3 years, 1 month ago
Tried to execute the code sample: 1) If acquires lease on the blob with null parameter, means the infinite lease is acquired [1] 2) On line 6 it gets reference to existing source blob, so no new blob is created there 3) It fails on start copy operation, because it tries to copy onto itself and the lease is already acquired 4) Goes to catch and then finally block 5) In finally breaks the lease with (Zero) parameter that means the immediate lease break [2] [1] https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.storage.blob.cloudblobcontainer.acquireleaseasync?view=azure-dotnet-legacy#microsoft-azure-storage-blob-cloudblobcontainer-acquireleaseasync(system-nullable((system-timespan))-system-string) [2] https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.storage.blob.cloudblobcontainer.breakleaseasync?view=azure-dotnet-legacy#microsoft-azure-storage-blob-cloudblobcontainer-breakleaseasync(system-nullable((system-timespan)))
upvoted 16 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago