AZ-204 Practice Question: Connect to and consume Azure services and third-party services
Exhibit
Refer to the exhibit. ```powershell $connectionString = "DefaultEndpointsProtocol=https;AccountName=mystorageaccount;AccountKey=mykey;EndpointSuffix=core.windows.net" $container = "mycontainer" $blobName = "myblob.txt" $content = "Hello World" $ctx = New-AzStorageContext -ConnectionString $connectionString Set-AzStorageBlobContent -Context $ctx -Container $container -File $content -Blob $blobName ```
You run the following PowerShell script to upload a blob to Azure Storage:
```powershell $context = New-AzStorageContext -StorageAccountName 'mystorageaccount' -StorageAccountKey 'fakekey...' Set-AzStorageBlobContent -Context $context -Container 'mycontainer' -Blob 'myblob' -File 'This is the file content' ```
The script fails with an error.
Which part of the script is causing the failure?
⚠ Common exam trap
Watch out — candidates often confuse the `-File` parameter (which expects a file path) with the `-Value` parameter (which accepts raw content), leading them to incorrectly assume the error is about storage account names, connection strings, or container existence.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The -File parameter should be a file path, not a string.
The script fails because the `-File` parameter of `Set-AzStorageBlobContent` expects a local file path, but the script passes raw content as a string literal. The cmdlet cannot find a file with that path, so it throws an error.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The storage account name 'mystorageaccount' is invalid.
Why it's wrong here
The error described does not indicate an invalid storage account name. If the storage account name 'mystorageaccount' were truly invalid or did not exist, the Set-AzStorageBlobContent cmdlet would typically fail much earlier with an error related to resource identification or authentication, such as "Storage account not found" or "ResourceNotFound". The problem statement points to an issue with the *content* parameter, implying the storage account itself was successfully resolved and accessible.
- ✗
The connection string format is incorrect.
Why it's wrong here
A malformed connection string would prevent the PowerShell cmdlet from establishing a proper authenticated connection to Azure Storage services. This would result in an immediate connection failure or authentication error, such as "Invalid connection string format" or "Authentication failed," before any attempt to upload blob content could even be made. Since the issue is described as related to the content parameter, the connection string format is presumed to be correct and functional, allowing initial communication with the storage service.
- ✓
The -File parameter should be a file path, not a string.
Why this is correct
The Set-AzStorageBlobContent cmdlet's -File parameter is specifically designed to accept a *local file path* as its argument. It expects to read content from an existing file on the local filesystem. If a literal string, such as "Hello World," is passed directly to -File, the cmdlet will attempt to interpret that string as a file path, which will fail because no such file exists, leading to an error during the content upload. To upload a string directly as blob content, the -Value parameter should be used instead.
- ✗
The container name 'mycontainer' does not exist.
Why it's wrong here
If the specified container 'mycontainer' did not exist in the target storage account, the Set-AzStorageBlobContent cmdlet would typically return a distinct error indicating a "ContainerNotFound" exception or a similar resource not found message. The problem description, however, specifies an error related to the *content* parameter. This suggests that the container was successfully identified, but the subsequent operation of writing the provided content to a blob within that container failed due to an incorrect content specification, not the container's absence.
Go deeper
Related to this question
About these practice questions
Courseiva writes every AZ-204 question from scratch — 883 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-204 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-204 exam.