title: DSC File Resource: Unable to connect to Azure File Storage using Credential Object
body: <p>I've been trying to make a DSC Script work using DSC File Resource to copy files from Azure File Storage to local as shown below</p>
  
  <pre><code> File FabrikamFibreSourceFiles
      {
          Ensure = "Present"  # You can also set Ensure to "Absent"
          Type = "Directory“ # Default is “File”
          Recurse = $true
          Credential = $storageCredential
          SourcePath = "\\sriksstore.file.core.windows.net\fabrikamfibreshare" # This is a path that has web files
          DestinationPath = "C:\inetpub\dev\fabrikamfibre\" # The path where we want to ensure the web files are present
      }
  </code></pre>
  
  <p>The $storageCredential is passed while invoking as shown below.</p>
  
  <pre><code>$storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName  -StorageAccountKey $storageKey
  $secpasswd = ConvertTo-SecureString $storageKey -AsPlainText -Force
  $storagecreds = New-Object System.Management.Automation.PSCredential ($storageAccountName, $secpasswd)
  
  Get-AzureVM -ServiceName fabrikamfibre -Name fabrikamfibre| `
  Set-AzureVMDscExtension -StorageContext $storageContext `
  -ConfigurationName "FabrikamFibre" -ConfigurationArgument @{ storageCredential= ($storagecreds) }`
  -ConfigurationArchive "fabrikamfibredsc.ps1.zip" | Update-AzureVM
  </code></pre>
  
  <p>It fails to copy the contents with the following errors </p>
  
  <p>An error occurs 
  when accessing the network share with the specified credential. Please make sure the credential is correct and the network 
  share is accessible. Note that Credential should not be specified with the local path.
  The related 
  file/directory is: \sriksstore.file.core.windows.net\fabrikamfibreshare.
  A specified logon session does not exist. It may already have been terminated. An error 
  occurs when accessing the network share with the specified credential. Please make sure the credential is correct and the 
  network share is accessible. Note that Credential should not be specified with the local path. The related file/directory is: 
  \sriksstore.file.core.windows.net\fabrikamfibreshare. </p>
  
  <p>It also fails when I try to invoke using Get-Credential as mentioned in various samples, if anyone tried using DSC File resource with Azure File Storage, please help. 
  I've double checked the credentials they are correct, interesting when I use write-verbose to print $storageCredential.Username they always output blank. I'm definitely missing something here.</p>