You are implementing a method in a C# application using the `Azure.Storage.Blobs` SDK (v12) to generate a temporary upload URI for a client. The client must be allowed to upload a single blob named `report.pdf` to a container named `documents`.
The implementation must meet the following security requirements:
- Limit permissions strictly to uploading the specified blob.
- Enforce the HTTPS protocol for the upload request.
- Sign the SAS using Microsoft Entra ID credentials rather than the storage account's shared access key.
- Prevent authentication failures due to clock skew between the client and Azure Storage.
You have the following code segment:
csharp
var credential = new DefaultAzureCredential();
var blobServiceClient = new BlobServiceClient(
new Uri("https://mystorage.blob.core.windows.net"),
credential
);
// [Block 1]
var sasBuilder = new BlobSasBuilder()
{
BlobContainerName = "documents",
BlobName = "report.pdf",
Resource = "b",
// [Block 2]
};
sasBuilder.SetPermissions(BlobSasPermissions.Write);
Which of the following code segments should you use to complete the implementation? (Select two.)
- For [Block 1]:
csharp
var userDelegationKey = await blobServiceClient.GetUserDelegationKeyAsync(
DateTimeOffset.UtcNow.AddMinutes(-15),
DateTimeOffset.UtcNow.AddHours(2)
);
Answer - For [Block 2]:
csharp
StartsOn = DateTimeOffset.UtcNow.AddMinutes(-15),
ExpiresOn = DateTimeOffset.UtcNow.AddHours(2),
Protocol = SasProtocol.Https
Answer - CFor [Block 1]:
csharp
var userDelegationKey = await blobServiceClient.GetUserDelegationKeyAsync(
DateTimeOffset.UtcNow,
DateTimeOffset.UtcNow.AddDays(30)
); - DFor [Block 2]:
csharp
StartsOn = DateTimeOffset.UtcNow,
ExpiresOn = DateTimeOffset.UtcNow.AddHours(2),
Protocol = SasProtocol.HttpsAndHttp