由于大小导致的 Azure Web 作业 Zip 部署错误

Azure Web Job Zip deployment Error due to Size

我正在通过 powershell 脚本部署 Web 作业,可以设法获取发布凭据,然后在授权中添加访问令牌 header。一切都很好,直到它在我收到文件大小错误时上传 zip 文件:远程服务器返回错误:(413) 请求实体太大。

#Function to get Publishing credentials for the WebApp :
        function Get-PublishingProfileCredentials($resourceGroupName, $AppServiceNameToDeployWebJobs) {

                $resourceType = "Microsoft.Web/sites/config"
                $resourceName = "$AppServiceNameToDeployWebJobs/publishingcredentials"
                $publishingCredentials = Invoke-AzResourceAction -ResourceGroupName $resourceGroupName -ResourceType `
                        $resourceType -ResourceName $resourceName -Action list -ApiVersion $Apiversion -Force
                return $publishingCredentials
        }

        #Pulling authorization access token :
        function Get-KuduApiAuthorisationHeaderValue($resourceGroupName, $AppServiceNameToDeployWebJobs) {

                $publishingCredentials = Get-PublishingProfileCredentials $resourceGroupName $AppServiceNameToDeployWebJobs
                return ("Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f `
                                                        $publishingCredentials.Properties.PublishingUserName, $publishingCredentials.Properties.PublishingPassword))))
        }


        $accessToken = Get-KuduApiAuthorisationHeaderValue $resourceGroupName $AppServiceNameToDeployWebJobs
        #Generating header to create and publish the Webjob :
        $Header = @{
                'Content-Disposition' = 'attachment; attachment; filename=Copy.zip'
                'Authorization'       = $accessToken
        }
        $apiUrl = "http://xxxx.scm.azurewebsites.net/app_data/jobs/triggered/Test/"
        $result = Invoke-RestMethod -Uri $apiUrl -Headers $Header -Method put `
        -InFile "D:\Work\WebJobs\WebJobsBuild\Test.zip" -ContentType 'application/zip' `
        -TimeoutSec 600 

zip 文件大小只有 43MB。如何检查允许的文件大小上限以及如何增加它? Invoke-WebRequest 和 Invoke-RestMethod 我都试过了,但结果是一样的

我修改了 $apiUrl,它对我有用。

应该是

$apiUrl = "https://$AppServiceNameToDeployWebJobs.scm.azurewebsites.net/api/triggeredwebjobs/MyWebJob1"

第 1 步。我在门户中测试 webjob,稍后我将创建 MyWebJob1

第 2 步。在 运行 命令之前。

第3步.修改web作业名称为MyWebJob1.

第 4 步。检查门户中的 webjob。

示例代码

    $resourceGroupName='***';
    $AppServiceNameToDeployWebJobs='jas***pp';
    $Apiversion='2019-08-01';

    #Function to get Publishing credentials for the WebApp :
    function Get-PublishingProfileCredentials($resourceGroupName, $AppServiceNameToDeployWebJobs) {

            $resourceType = "Microsoft.Web/sites/config"
            $resourceName = "$AppServiceNameToDeployWebJobs/publishingcredentials"
            $publishingCredentials = Invoke-AzResourceAction -ResourceGroupName $resourceGroupName -ResourceType `
                    $resourceType -ResourceName $resourceName -Action list -ApiVersion $Apiversion -Force
            return $publishingCredentials
    }

    #Pulling authorization access token :
    function Get-KuduApiAuthorisationHeaderValue($resourceGroupName, $AppServiceNameToDeployWebJobs) {

            $publishingCredentials = Get-PublishingProfileCredentials $resourceGroupName $AppServiceNameToDeployWebJobs
            return ("Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f `
                                                    $publishingCredentials.Properties.PublishingUserName, $publishingCredentials.Properties.PublishingPassword))))
    }


    $accessToken = Get-KuduApiAuthorisationHeaderValue $resourceGroupName $AppServiceNameToDeployWebJobs
    #Generating header to create and publish the Webjob :
    $Header = @{
            'Content-Disposition' = 'attachment; attachment; filename=test.zip'
            'Authorization'       = $accessToken
    }
    $apiUrl = "https://$AppServiceNameToDeployWebJobs.scm.azurewebsites.net/api/triggeredwebjobs/MyWebJob1" 
    $result = Invoke-RestMethod -Uri $apiUrl -Headers $Header -Method put `
    -InFile "E:\test.zip" -ContentType 'application/zip' `
    -TimeoutSec 600