You are developing a secure backend service in C# using the Azure.Storage.Blobs SDK (v12) to grant temporary access for clients to upload diagnostic files to a private Azure Blob Storage container.
Your company enforces the following security requirements:
- Storage account access keys must not be used or loaded by the application; access must be authenticated via Microsoft Entra ID.
- Clients must only be permitted to write new files; they must not be allowed to read, list, or delete existing files.
- All client connections must be encrypted using HTTPS.
- The SAS token must be valid immediately upon generation, accounting for potential clock synchronization differences between the server and clients.
You write the following code segment:
csharp
// blobServiceClient is an authenticated BlobServiceClient using DefaultAzureCredential
var userDelegationKey = await blobServiceClient.GetUserDelegationKeyAsync(
DateTimeOffset.UtcNow.AddMinutes(-15),
DateTimeOffset.UtcNow.AddHours(2)
);
var sasBuilder = new BlobSasBuilder
{
BlobContainerName = "diagnostics",
BlobName = "log.txt",
Resource = "b"
};
Which code segment should you use to complete the SAS configuration and token generation?
- AsasBuilder.StartsOn = DateTimeOffset.UtcNow.AddMinutes(-15);
sasBuilder.ExpiresOn = DateTimeOffset.UtcNow.AddMinutes(45);
sasBuilder.Protocol = SasProtocol.HttpsAndHttp;
sasBuilder.SetPermissions(BlobSasPermissions.Write);
string sasToken = sasBuilder.ToSasQueryParameters(userDelegationKey, blobServiceClient.AccountName).ToString(); - sasBuilder.StartsOn = DateTimeOffset.UtcNow.AddMinutes(-15);
sasBuilder.ExpiresOn = DateTimeOffset.UtcNow.AddMinutes(45);
sasBuilder.Protocol = SasProtocol.Https;
sasBuilder.SetPermissions(BlobSasPermissions.Write);
string sasToken = sasBuilder.ToSasQueryParameters(userDelegationKey, blobServiceClient.AccountName).ToString();Cevap - CsasBuilder.StartsOn = DateTimeOffset.UtcNow.AddMinutes(-15);
sasBuilder.ExpiresOn = DateTimeOffset.UtcNow.AddMinutes(45);
sasBuilder.Protocol = SasProtocol.Https;
sasBuilder.SetPermissions(BlobSasPermissions.Write);
var credential = new StorageSharedKeyCredential(blobServiceClient.AccountName, "accountKey");
string sasToken = sasBuilder.ToSasQueryParameters(credential).ToString(); - DsasBuilder.StartsOn = DateTimeOffset.UtcNow;
sasBuilder.ExpiresOn = DateTimeOffset.UtcNow.AddMinutes(45);
sasBuilder.Protocol = SasProtocol.Https;
sasBuilder.SetPermissions(BlobSasPermissions.Read | BlobSasPermissions.Write);
string sasToken = sasBuilder.ToSasQueryParameters(userDelegationKey, blobServiceClient.AccountName).ToString();