Azure Files - 409 conflict with read-only files

457 views Asked by At

I know Azure Files is still in preview but bear with me... My users have the ability to upload a file to an Azure Files directory and, every so often, the file is marked as read-only on the source file system. We also have an automated process to update those files. When the destination file is marked as read-only, the automated process fails with a 409 Conflict message.

Does anyone know how to determine if the file is read-only or not on Azure Files?

I've attached sample code below. The error occur during the call to UploadFromStream.

     private void downloadBlobToAzureFiles( string containerName, string blobName, string destinationFilePath, Guid callID )
    {
       var container = this.destBlobClient.GetContainerReference( containerName );
       var blob = container.GetBlockBlobReference( blobName.ToLower() );
       MemoryStream memStream = new MemoryStream();
       blob.DownloadToStream( memStream );
       memStream.Seek( 0, SeekOrigin.Begin );

       //split directory path and filename
       var fileInfo = new SplitFilePathInfo( destinationFilePath );

       var fileDirectory = this.rootDirectory;
       foreach( var dir in fileInfo.Path.Split( '\\' ) )
       {
           if( string.IsNullOrEmpty( dir ) ) continue;

           fileDirectory = fileDirectory.GetDirectoryReference( dir );
           fileDirectory.CreateIfNotExists();
       }

       CloudFile cloudFile = fileDirectory.GetFileReference( fileInfo.FileName );
       cloudFile.UploadFromStream( memStream );
}
0

There are 0 answers