2016-10-27 60 views
0

Azureストレージにxml(たとえば)を作成し、そのファイルをSFTPサーバーに直接アップロードしたいとします。ファイルをAzure Storage BlobからSFTPに転送するときに問題が発生する

string name = DateTime.Now.ToString("yyyyMMddhhmmss") + ".xml"; 

     // Retrieve storage account from connection string. 
     CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString")); 

     // Create the blob client. 
     CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); 

     // Retrieve a reference to a container. 
     CloudBlobContainer container = blobClient.GetContainerReference("xxxxxxxxxxxx"); 

     // Create the container if it doesn't already exist. 
     container.CreateIfNotExists(); 

     //Create reference to a Blob that May or Maynot exist under the container 
     CloudBlockBlob blockBlob = container.GetBlockBlobReference(name); 

     // Create or overwrite the "something.xml" blob with contents from a string 

     string xml = "some xml"; 

     blockBlob.UploadTextAsync(xml); 

     //Upload file to the sftp server 
     string fpath = "https://someazureserver.blob.core.windows.net/xxxxxxxxx/" + name; 

     sftp.Connect(); 
     try 
     { 
      string INVENTORY = "xxxx/xxxx/xxxx"; //the file path in sftp 
      sftp.Put(fpath, INVENTORY); 
     } 
     finally { sftp.Close(); } 

私はそのブロブのURLへのファイルパスを記入しようとしましたが、それは動作しませんでした。私はオンラインで検索しましたが、BLOBファイルのパスについては何も見つかりませんでした。 azureからsftpにファイルを転送する別の方法はありますか? ありがとうございました!

答えて

0

sftpクライアントがHTTP経由でデータを取得できると仮定すると、blobはパブリックアクセスを許可するように構成されていないコンテナに格納されていると考えられます。 Fiddlerを実行してコードを実行すると、sftpがファイルを取得しようとしたときにサーバー認証エラーが表示されることが予想されます。この場合、ファイルへのアクセスを可能にするURLと共にSASトークンを提供するか、またはパブリックアクセスを許可するようにコンテナを構成することができます。詳細については、以下の記事を参照してください:

+0

がえーえ、私はちょうどマイクロソフトQAを確認し、彼らは私にとってとてもGGまだこの機能を持っていけません。私はそれを行う別の方法を見つける必要があるように見えます。とにかくありがとう!!私はあなたの答えを使用するつもりです。 –

関連する問題