2

我真的很接近完成我的工作,但它开始导致这个错误。

当我执行这个

Save-AzureWebSiteLog -Name $WebSiteName -Output "C:\logs\error.zip"

Save-AzureWebSiteLog :已超出传入消息 (65536) 的最大消息大小配额。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性。

所以,我搜索了解决方案,似乎很多人都有完全相同的问题。

https://azure.microsoft.com/en-us/blog/windows-azure-websites-online-tools-you-should-know-about/

感谢@Parth Sehgal,我试图通过使用powershell来解决这个问题

$username = "maiemai"
$password = "Password"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
$apiUrl = "https://wngphase2it.scm.azurewebsites.net/api/zip/LogFiles/"
$response = Invoke-WebRequest -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method GET 
try
{
$filename = [System.IO.Path]::GetFileName($response.BaseResponse.ResponseUri.OriginalString)
$filepath = [System.IO.Path]::Combine("c:\asdf\", "http1.zip")
$filestream = [System.IO.File]::Create($filepath)
$response.RawContentStream.WriteTo($filestream)
}
finally
{
$filestream.Close()
}

但我被这个错误困住了

Invoke-WebRequest:服务器错误 401 - 未经授权:由于凭据无效,访问被拒绝。您无权使用您提供的凭据查看此目录或页面。在 line:5 char:13 + $response = Invoke-WebRequest -Uri $apiUrl -Headers @{Authorization=("Basic {0}" ... + ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand 你不能在空值表达式上调用方法。在 line:11 char:1 + $response.RawContentStream。

用户名和密码绝对正确,但仍然导致此错误。

我应该如何改变这条线?

$response = Invoke-WebRequest -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method GET 
4

1 回答 1

3

首先,在这种情况下,您的用户名不正确。

为了使用 Azure Kudu REST API 检索 Azure Web 应用的压缩日志文件,您需要在发布配置文件中使用 Web 应用的MSDeploy 凭据。

Azure Web 应用的 MSDeploy 用户名的正确形式应该是${yoursitename}

您可以从新的 Azure 门户或通过 Azure PowerShell 命令获取 Web 应用的发布配置文件:Get-AzureRMWebAppPublishingProfile

我还在您使用自己的 Web 应用程序测试的 PowerShell 脚本中解决了这个问题。

$username = "`$wngphase2it"
$password = "yourMSDeployUserPwd"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
$apiUrl = "https://wngphase2it.scm.azurewebsites.net/api/zip/LogFiles/"
$response = Invoke-WebRequest -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method GET 
try
{
$filename = [System.IO.Path]::GetFileName($response.BaseResponse.ResponseUri.OriginalString)
$filepath = [System.IO.Path]::Combine("c:\asdf\", "http1.zip")
$filestream = [System.IO.File]::Create($filepath)
$response.RawContentStream.WriteTo($filestream)
}
finally
{
$filestream.Close()
}

参考:使用 Kudu REST API 和 PowerShell 的示例

让我知道它是否有助于解决您的问题。

于 2016-01-06T07:12:29.620 回答