Azure powershell error: A drive with the name 'D' does not exist

DiBok 11 Reputation points
2022-10-28T11:42:10.643+00:00

I'm trying to setup Azure devops build pipeline using Bicep script.

Pipeline looks like this:

  • .Net Core Restore task
  • .Net Core Build task
  • .Net Core Publish task
  • Publish build artifacts
  • ARM Template deployment

Task "Publish artifact" creates a "a.zip" file into "drop" folder using path to publish $(Build.ArtifactStagingDirectory)

If I try to output Build.ArtifactStagingDirectory with the help of inline powershell script:

Write-Host "Build.ArtifactStagingDirectory="$(Build.ArtifactStagingDirectory)  

it shows me path Build.ArtifactStagingDirectory= D:\a\1\a

Now, inside bicep file I'm creating: azure storage account and azure functions app.

Functions app require a zip file stored on storage account during function app creation. This parameter is called: WEBSITE_RUN_FROM_PACKAGE

As I understand, bicep can't copy files, for this we have powershell script and inside bicep such resource is called "Microsoft.Resources/deploymentScripts@2020-10-01"

So, after creating storage account in bicep, I'm trying to run powershell script to copy my build artifact (a.zip file containing files of azure functions contents) from $(Build.ArtifactStagingDirectory) to azure blob storage.

powershell script tools like this:

$storageAccount = Get-AzStorageAccount -ResourceGroupName $env:ResourceGroupName -AccountName $env:StorageAccountName  
  
$ctx = $storageAccount.Context  
  
Set-AzStorageBlobContent -Context $ctx -Container $env:Container -File $env:FileDrop -Blob $env:StorageFileName -Properties @{'ContentType' = 'application/zip'} -Force  

where

  • $env:FileDrop is the path to $(Build.ArtifactStagingDirectory)\drop\a.zip
  • $env:StorageFileName is just a blob name "a.zip"

But I always get the error message:

Cannot find drive. A drive with the name 'D' does not exist.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,321 questions
{count} votes