You are developing a Python background utility to safely update a shared configuration file stored in Azure Blob Storage. The application uses the azure-storage-blob SDK (v12).
To prevent concurrent writes, the application first acquires a lease on the blob using the following code:
python
from azure.storage.blob import BlobServiceClient, BlobLeaseClient
connection_string = "UseDevelopmentStorage=true"
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
blob_client = blob_service_client.get_blob_client(container="configs", blob="appsettings.json")
# Acquire a 30-second lease on the blob
lease_client = BlobLeaseClient(blob_client)
lease_client.acquire(lease_duration=30)
# Modify the configuration data
updated_config_data = b'{"status": "ready", "version": "2.0"}'
Which of the following code statements must you use to upload the updated configuration to the leased blob?
- blob_client.upload_blob(updated_config_data, overwrite=True, lease=lease_client)Answer
- Bblob_client.upload_blob(updated_config_data, overwrite=True)
- Cblob_client.upload_blob(updated_config_data, overwrite=True, lease_id=lease_client.lease_id)
- Dblob_client.upload_blob(updated_config_data, overwrite=True, headers={"x-ms-lease-id": lease_client.lease_id})