0
0
Azurecloud~10 mins

Connection from applications in Azure - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the connection string for an Azure Storage account.

Azure
connection_string = "DefaultEndpointsProtocol=https;AccountName=[1];AccountKey=your_key;EndpointSuffix=core.windows.net"
Drag options to blanks, or click blank then click option'
AmyStorageAccount
BmyResourceGroup
CmyContainer
DmySubscription
Attempts:
3 left
💡 Hint
Common Mistakes
Using the resource group name instead of the storage account name.
Using the container name in the connection string.
2fill in blank
medium

Complete the code to create a BlobServiceClient using the connection string.

Azure
from azure.storage.blob import BlobServiceClient
client = BlobServiceClient.from_connection_string([1])
Drag options to blanks, or click blank then click option'
Acontainer_name
Baccount_key
Cconnection_string
Dendpoint_suffix
Attempts:
3 left
💡 Hint
Common Mistakes
Passing only the account key instead of the full connection string.
Passing the container name instead of the connection string.
3fill in blank
hard

Fix the error in the code to upload a blob to Azure Blob Storage.

Azure
blob_client = client.get_blob_client(container=[1], blob='example.txt')
with open('example.txt', 'rb') as data:
    blob_client.upload_blob(data)
Drag options to blanks, or click blank then click option'
A'mycontainer'
BmyContainer
Ccontainer_name
D'myContainer'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the container name without quotes causing a NameError.
Using incorrect casing for container names.
4fill in blank
hard

Fill both blanks to list blobs in a container and print their names.

Azure
container_client = client.get_container_client([1])
for blob in container_client.[2]():
    print(blob.name)
Drag options to blanks, or click blank then click option'
A'mycontainer'
Blist_blobs
Cget_blobs
D'container1'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable without quotes for container name.
Using a non-existent method get_blobs().
5fill in blank
hard

Fill all three blanks to download a blob and save it locally.

Azure
blob_client = client.get_blob_client(container=[1], blob=[2])
with open([3], 'wb') as file:
    data = blob_client.download_blob()
    file.write(data.readall())
Drag options to blanks, or click blank then click option'
A'mycontainer'
B'example.txt'
C'downloaded_example.txt'
D'localfile.txt'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around container or blob names.
Using the same name for local file and blob without quotes.