2017-05-22 12 views
-2

AndroidアプリのためにC#を使用して、ダウンロードを記録します私は紺碧のポータルからプログラムまたは手動でこれを行うことができますどのようにC#のコードを使用してテキストファイルにAndroidアプリのための紺碧のログをダウンロードする必要があり、マイクロソフトのAzureアプリのログにアクセスするための任意のAPIはありますか?マイクロソフトのAzureは

私はテキストファイルにこれらのログをダウンロードする必要があり、参照のために添付された画像を見つけてください。

Azure Screenshot

+0

そして、あなたがこれまでに試してみましたか?ここにあなたの要件を落とす以外に? – GhostCat

+0

はありがとうございました...私は、インスタンス名、および提供されるキーの必要性については明らかではないよソリューション –

答えて

1

あなたがC#アプリケーションにMicrosoft.WindowsAzure名前空間を使用する必要があります。ここで

IISログファイルをダウンロードするためのいくつかのコードは:ここでは

 string directory = "[path to save files]"; 
     string instance = "[Azure instance name]"; 
     string key = "[Azure key]"; 


     var account = new CloudStorageAccount(
     new StorageCredentialsAccountAndKey(
     instance, 
     key 
     ), 
    false 
    ); 

     var client = account.CreateCloudBlobClient(); 
     var container = client.GetContainerReference("wad-iis-logfiles"); 

     //note that I pass the BlobRequestOptions of UseFlatBlobListing which returns all files regardless 
     //of nesting so that I don't have to walk the directory structure 
     foreach (var blob in container.ListBlobs(new BlobRequestOptions() { UseFlatBlobListing = true })) 
     { 
      CloudBlob b = blob as CloudBlob; 
      try 
      { 
       b.FetchAttributes(); 
       BlobAttributes blobAttributes = b.Attributes; 
       TimeSpan span = DateTime.Now.Subtract(blobAttributes.Properties.LastModifiedUtc.ToLocalTime()); 
       int compare = TimeSpan.Compare(span, TimeSpan.FromHours(1)); 
       //we don't want to download and delete the latest log file, because it is incomplete and still being 
       //written to, thus this compare logic 
       if (compare == 1) 
       { 
        b.DownloadToFile(directory + b.Uri.PathAndQuery); 
        b.Delete(); 
       } 
      } 
      catch (Exception e) 
      { 
       Console.WriteLine(instance + " download of logs failed!!!!" + e.Message); 
       return; 
      } 

     } 
     Console.WriteLine(instance + " download of logs complete at " + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString() + ""); 

をダウンロードし、任意のAzureのインスタンスからログを削除する方法の例です:https://code.msdn.microsoft.com/windowsdesktop/Azure-Log-Fetcher-522ff173

+0

を得ましたか。 –

関連する問題