You are developing a secure .NET web application using the `Azure.Storage.Blobs` SDK (v12). The application must generate a Shared Access Signature (SAS) token for an Azure Blob Storage container named `invoices`.
The security requirements are as follows:
- The token must be signed using Microsoft Entra ID credentials (a User Delegation SAS) instead of the storage account key.
- The client must only be allowed to read and list the contents of the container.
- The SAS must restrict access to requests originating from the client IP address range `198.51.100.0/24`.
- The token must enforce the use of HTTPS only.
- The token must account for potential clock skew by setting the start time to 15 minutes before the current time.
You write the following method to generate the SAS token:
csharp
public async Task<string> GenerateContainerSasUriAsync(BlobServiceClient client, string containerName, string accountName)
{
UserDelegationKey delegationKey = await client.GetUserDelegationKeyAsync(
DateTimeOffset.UtcNow.AddMinutes(-15),
DateTimeOffset.UtcNow.AddHours(2)
);
BlobSasBuilder builder = new BlobSasBuilder()
{
BlobContainerName = containerName,
Resource = "c",
StartsOn = DateTimeOffset.UtcNow.AddMinutes(-15),
ExpiresOn = DateTimeOffset.UtcNow.AddHours(2)
};
// INSERT CODE HERE
BlobSasQueryParameters sasParams = builder.ToSasQueryParameters(delegationKey, accountName);
return $"{client.Uri}{containerName}?{sasParams}";
}
Which code segment should you insert to complete the method and meet the requirements?
- Abuilder.SetPermissions(BlobSasPermissions.Read | BlobSasPermissions.List);
builder.Protocol = SasProtocol.Https;
builder.IPRange = IPAddressRange.Parse("198.51.100.0/24"); - Bbuilder.SetPermissions(BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List);
builder.Protocol = SasProtocol.HttpsAndHttp;
builder.IPRange = IPAddressRange.Parse("198.51.100.0/24"); - builder.SetPermissions(BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List);
builder.Protocol = SasProtocol.Https;
builder.IPRange = IPAddressRange.Parse("198.51.100.0/24");Answer - Dbuilder.SetPermissions(BlobAccountSasPermissions.Read | BlobAccountSasPermissions.List);
builder.Protocol = SasProtocol.Https;
builder.IPRange = IPAddressRange.Parse("198.51.100.0/24");