projectkudu / kudu

Kudu is the engine behind git/hg deployments, WebJobs, and various other features in Azure Web Sites. It can also run outside of Azure.
Apache License 2.0
3.13k stars 652 forks source link

ZipDeploy RunFromPackage crashing #3331

Closed mmaitre314 closed 7 months ago

mmaitre314 commented 3 years ago

For deployment issues, please provide us with the following information:

Repro steps.

Following wiki ARMTemplate:-RunFromPackage-sample I created the following ARM template with an Azure Function on Linux running from zip package. ARM deployment fails with HTTP 400. Going through the code it looks like zipDeploymentInfo.ArtifactFileName is null in PushDeploymentController.WriteSitePackageZip() here.

{
  "type": "Microsoft.Storage/storageAccounts",
  "apiVersion": "2019-06-01",
  "name": "testmmaitre1234",
  "location": "westus2",
  "kind": "StorageV2",
  "sku": {
    "name": "Standard_LRS"
  },
  "properties": {
    "supportsHttpsTrafficOnly": true,
    "allowBlobPublicAccess": false,
    "minimumTlsVersion": "TLS1_2"
  }
},
{
  "type": "Microsoft.Web/serverfarms",
  "apiVersion": "2021-01-15",
  "name": "testmmaitre1234",
  "location": "westus2",
  "sku": {
    "tier": "ElasticPremium",
    "name": "EP1"
  },
  "properties": {
    "name": "testmmaitre1234",
    "computeMode": "Dynamic",
    "reserved": true // OS = Linux
  }
},
{
  "name": "testmmaitre1234",
  "type": "Microsoft.Web/sites",
  "kind": "functionapp,linux",
  "apiVersion": "2020-06-01",
  "location": "westus2",
  "dependsOn": [
    "Microsoft.Storage/storageAccounts/testmmaitre1234",
    "Microsoft.Web/serverfarms/testmmaitre1234"
  ],
  "properties": {
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', 'testmmaitre1234')]",
    "clientAffinityEnabled": false,
    "httpsOnly": true,
    "siteConfig": {
      "http20Enabled": true,
      "minTlsVersion": "1.2",
      "ftpsState": "Disabled",
      "linuxFxVersion": "DOTNET-ISOLATED|5.0",
      "appSettings": [
        {
          "name": "AzureWebJobsDashboard",
          "value": "[concat('DefaultEndpointsProtocol=https;AccountName=testmmaitre1234;EndpointSuffix=', environment().suffixes.storage, ';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', 'testmmaitre1234'), '2019-06-01').keys[0].value)]"
        },
        {
          "name": "AzureWebJobsStorage",
          "value": "[concat('DefaultEndpointsProtocol=https;AccountName=testmmaitre1234;EndpointSuffix=', environment().suffixes.storage, ';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', 'testmmaitre1234'), '2019-06-01').keys[0].value)]"
        },
        {
          "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
          "value": "[concat('DefaultEndpointsProtocol=https;AccountName=testmmaitre1234;EndpointSuffix=', environment().suffixes.storage, ';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', 'testmmaitre1234'), '2019-06-01').keys[0].value)]"
        },
        {
          "name": "AzureWebJobsSecretStorageType",
          "value": "Files"
        },
        {
          "name": "WEBSITE_CONTENTSHARE",
          "value": "testmmaitre1234"
        },
        {
          "name": "FUNCTIONS_EXTENSION_VERSION",
          "value": "~3"
        },
        {
          "name": "FUNCTIONS_WORKER_RUNTIME",
          "value": "dotnet-isolated"
        },
        {
          "name": "WEBSITE_RUN_FROM_PACKAGE",
          "value": "1"
        }
      ]
    }
  },
  "resources": [
    {
      "name": "ZipDeploy",
      "type": "Extensions",
      "apiVersion": "2016-03-01",
      "dependsOn": [
        "Microsoft.Web/sites/testmmaitre1234"
      ],
      "properties": {
        "packageUri": "https://testmmaitre1234.blob.core.windows.net/packages/AzureFunction/v1.zip?sp=rl&st=2021-09-08T15:05:16Z&se=2021-09-09T15:05:16Z&sv=2020-08-04&sr=c&sig=<snip>"
      }
    }
  ]
}

The ARM template deployment fails with:

{
    "status": "Failed",
    "error": {
        "code": "BadRequest",
        "message": ""
    }
}

Project structures.

Any zipped Azure Function should do.

The log/error given by the failure.

In Kudu Bash Console:

/home>cat /home/LogFiles/kudu/trace/2021-09-08T16-41-59_364c7d_002_PUT_ZipDeploy_pending.xml
<step title="Incoming Request" date="2021-09-08T16:41:59.702" instance="364c7d" url="/ZipDeploy?api-version=2016-03-01" method="PUT" type="request" pid="66,1,6" Connection="Keep-Alive" Content-Type="application/json; charset=utf-8" Accept-Encoding="gzip, deflate" Accept-Language="en-US" Host="testmmaitre1234.scm.azurewebsites.net" Referer="https://management.azure.com/subscriptions/23782349-c970-4549-acbb-7ed9d00ebb32/resourcegroups/AzD4AI-mmaitre/providers/Microsoft.Web/sites/testmmaitre1234/Extensions/ZipDeploy?api-version=2016-03-01" User-Agent="azure-resource-manager/2.0" traceparent="00-f8b0627bdf2cb04abb4c9aa91c52625f-70dc94b2e8300d42-01" Content-Length="249" X-Client-IP="13.66.140.0" X-Client-Port="1793" x-ms-client-request-id="f713d730-9ae0-4b91-a1c9-d0555f8803fd" x-ms-client-location="westus2" x-ms-arm-resource-system-data="{&quot;createdBy&quot;:&quot;mmaitre@microsoft.com&quot;,&quot;createdByType&quot;:&quot;User&quot;,&quot;createdAt&quot;:&quot;2021-09-08T16:41:59.4160837Z&quot;,&quot;lastModifiedBy&quot;:&quot;mmaitre@microsoft.com&quot;,&quot;lastModifiedByType&quot;:&quot;User&quot;,&quot;lastModifiedAt&quot;:&quot;2021-09-08T16:41:59.4160837Z&quot;}" x-ms-arm-service-request-id="9544ef75-391b-4372-b547-a31dd64e1296" x-ms-arm-initiator-job="eyJsb2NhdGlvbiI6Indlc3R1czIiLCJwYXJ0aXRpb24iOiIyMzc4MjM0OUM5NzA0NTQ5QUNCQjdFRDlEMDBFQkIzMiIsImlkIjoiRGVwbG95bWVudEpvYjozQTJEQVpENEFJOjNBM0EyRE1NQUlUUkU6M0EyREFaRDRBSTozQTNBMjo3QzMzOTExMDNGNTVDMDc2MkEtOUVDRkREMjhDOEY4NTJEMiJ9" x-ms-activity-vector="IN.0S.IN.0J" x-ms-arm-request-tracking-id="272a1dd3-5f52-405e-ab1a-17901d923508" x-ms-correlation-request-id="56c4c0ee-39a3-4bd4-9c4b-a741353e7cd6" x-ms-routing-request-id="WESTUS2:20210908T164159Z:272a1dd3-5f52-405e-ab1a-17901d923508" x-ms-home-tenant-id="72f988bf-86f1-41af-91ab-2d7cd011db47" x-ms-client-ip-address="97.113.136.29" x-ms-management-group-ancestors="b01d773d-e006-4f66-99ab-ed6c7624b4c1, 48fed3a1-0814-4847-88ce-b766155f2792, CnAIOrchestrationServicePublicCorpprod, 72f988bf-86f1-41af-91ab-2d7cd011db47" x-ms-client-audience="https://management.core.windows.net/" x-ms-client-scope="user_impersonation" x-ms-client-acr="1" x-ms-client-app-id="1950a258-227b-4e31-a9cf-717495945fc2" x-ms-client-app-id-acr="0" x-ms-client-tenant-id="72f988bf-86f1-41af-91ab-2d7cd011db47" x-ms-client-issuer="https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/" x-ms-client-object-id="ac990eb3-b25a-4e06-ade5-41c7613693ff" x-ms-client-puid="10030000801C3BC2" x-ms-client-alt-sec-id="" x-ms-client-principal-id="10030000801C3BC2" x-ms-client-authorization-source="Legacy" x-ms-client-identity-provider="" x-ms-client-wids="b79fbf4d-3ef9-4689-8143-76b194e85509" x-ms-client-authentication-methods="rsa, wia, mfa" x-ms-client-principal-group-membership-source="Graph" x-ms-client-family-name-encoded="TWFpdHJl" x-ms-client-given-name-encoded="TWF0dGhpZXU=" x-ms-arm-network-source="PublicNetwork" x-ms-via-extensions-route="true" x-ms-geo-location="West US 2" x-ms-version="20140301" x-ms-request-id="282eaf9f-9cea-4cb1-a2ee-3a4f3335c3e9" X-WAWS-Unencoded-URL="/ZipDeploy?api-version=2016-03-01" CLIENT-IP="13.66.140.0:1793" X-ARR-LOG-ID="282eaf9f-9cea-4cb1-a2ee-3a4f3335c3e9" X-SITE-DEPLOYMENT-ID="testmmaitre1234" WAS-DEFAULT-HOSTNAME="testmmaitre1234.scm.azurewebsites.net" X-Forwarded-Proto="https" X-AppService-Proto="https" X-Forwarded-TlsVersion="1.2" >
  <step title="Cleanup Xml Logs" date="2021-09-08T16:41:59.718" /><!-- duration: 34ms -->
  <step title="ZipPushDeployViaUrl" date="2021-09-08T16:42:00.694" >
    <step title="Reading the artifact URL from the ARM request JSON" date="2021-09-08T16:42:00.749" /><!-- duration: 32ms -->
  </step><!-- duration: 140ms -->
  <step title="Error occurred" date="2021-09-08T16:42:02.227" type="error" text="Value cannot be null. (Parameter &apos;path2&apos;)" stackTrace="   at System.IO.Path.Combine(String path1, String path2)
   at Kudu.Services.Deployment.PushDeploymentController.WriteSitePackageZip(ArtifactDeploymentInfo zipDeploymentInfo, ITracer tracer)
   at Kudu.Services.Deployment.PushDeploymentController.PushDeployAsync(ArtifactDeploymentInfo deploymentInfo, Boolean isAsync, HttpContext context, JObject requestJson)
   at Kudu.Services.Deployment.PushDeploymentController.ZipPushDeployViaUrl(JObject requestJson, Boolean isAsync, Boolean syncTriggers, Boolean overwriteWebsiteRunFromPackage, String author, String authorEmail, String deployer, String message, Boolean trackDeploymentProgress)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&lt;InvokeActionMethodAsync&gt;g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&lt;InvokeNextActionFilterAsync&gt;g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State&amp; next, Scope&amp; scope, Object&amp; state, Boolean&amp; isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeNextResourceFilter&gt;g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State&amp; next, Scope&amp; scope, Object&amp; state, Boolean&amp; isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeAsync&gt;g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)
   at Kudu.Services.Web.Tracing.TraceMiddleware.Invoke(HttpContext context)" /><!-- duration: 58ms -->
  <step title="Incoming Request" date="2021-09-08T16:42:02.343" url="/Error?api-version=2016-03-01" method="PUT" type="request" pid="66,1,13" Connection="Keep-Alive" Content-Type="application/json; charset=utf-8" Accept-Encoding="gzip, deflate" Accept-Language="en-US" Host="testmmaitre1234.scm.azurewebsites.net" Referer="https://management.azure.com/subscriptions/23782349-c970-4549-acbb-7ed9d00ebb32/resourcegroups/AzD4AI-mmaitre/providers/Microsoft.Web/sites/testmmaitre1234/Extensions/ZipDeploy?api-version=2016-03-01" User-Agent="azure-resource-manager/2.0" traceparent="00-f8b0627bdf2cb04abb4c9aa91c52625f-70dc94b2e8300d42-01" Content-Length="249" X-Client-IP="13.66.140.0" X-Client-Port="1793" x-ms-client-request-id="f713d730-9ae0-4b91-a1c9-d0555f8803fd" x-ms-client-location="westus2" x-ms-arm-resource-system-data="{&quot;createdBy&quot;:&quot;mmaitre@microsoft.com&quot;,&quot;createdByType&quot;:&quot;User&quot;,&quot;createdAt&quot;:&quot;2021-09-08T16:41:59.4160837Z&quot;,&quot;lastModifiedBy&quot;:&quot;mmaitre@microsoft.com&quot;,&quot;lastModifiedByType&quot;:&quot;User&quot;,&quot;lastModifiedAt&quot;:&quot;2021-09-08T16:41:59.4160837Z&quot;}" x-ms-arm-service-request-id="9544ef75-391b-4372-b547-a31dd64e1296" x-ms-arm-initiator-job="eyJsb2NhdGlvbiI6Indlc3R1czIiLCJwYXJ0aXRpb24iOiIyMzc4MjM0OUM5NzA0NTQ5QUNCQjdFRDlEMDBFQkIzMiIsImlkIjoiRGVwbG95bWVudEpvYjozQTJEQVpENEFJOjNBM0EyRE1NQUlUUkU6M0EyREFaRDRBSTozQTNBMjo3QzMzOTExMDNGNTVDMDc2MkEtOUVDRkREMjhDOEY4NTJEMiJ9" x-ms-activity-vector="IN.0S.IN.0J" x-ms-arm-request-tracking-id="272a1dd3-5f52-405e-ab1a-17901d923508" x-ms-correlation-request-id="56c4c0ee-39a3-4bd4-9c4b-a741353e7cd6" x-ms-routing-request-id="WESTUS2:20210908T164159Z:272a1dd3-5f52-405e-ab1a-17901d923508" x-ms-home-tenant-id="72f988bf-86f1-41af-91ab-2d7cd011db47" x-ms-client-ip-address="97.113.136.29" x-ms-management-group-ancestors="b01d773d-e006-4f66-99ab-ed6c7624b4c1, 48fed3a1-0814-4847-88ce-b766155f2792, CnAIOrchestrationServicePublicCorpprod, 72f988bf-86f1-41af-91ab-2d7cd011db47" x-ms-client-audience="https://management.core.windows.net/" x-ms-client-scope="user_impersonation" x-ms-client-acr="1" x-ms-client-app-id="1950a258-227b-4e31-a9cf-717495945fc2" x-ms-client-app-id-acr="0" x-ms-client-tenant-id="72f988bf-86f1-41af-91ab-2d7cd011db47" x-ms-client-issuer="https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/" x-ms-client-object-id="ac990eb3-b25a-4e06-ade5-41c7613693ff" x-ms-client-puid="10030000801C3BC2" x-ms-client-alt-sec-id="" x-ms-client-principal-id="10030000801C3BC2" x-ms-client-authorization-source="Legacy" x-ms-client-identity-provider="" x-ms-client-wids="b79fbf4d-3ef9-4689-8143-76b194e85509" x-ms-client-authentication-methods="rsa, wia, mfa" x-ms-client-principal-group-membership-source="Graph" x-ms-client-family-name-encoded="TWFpdHJl" x-ms-client-given-name-encoded="TWF0dGhpZXU=" x-ms-arm-network-source="PublicNetwork" x-ms-via-extensions-route="true" x-ms-geo-location="West US 2" x-ms-version="20140301" x-ms-request-id="282eaf9f-9cea-4cb1-a2ee-3a4f3335c3e9" X-WAWS-Unencoded-URL="/ZipDeploy?api-version=2016-03-01" CLIENT-IP="13.66.140.0:1793" X-ARR-LOG-ID="282eaf9f-9cea-4cb1-a2ee-3a4f3335c3e9" X-SITE-DEPLOYMENT-ID="testmmaitre1234" WAS-DEFAULT-HOSTNAME="testmmaitre1234.scm.azurewebsites.net" X-Forwarded-Proto="https" X-AppService-Proto="https" X-Forwarded-TlsVersion="1.2" >
    <step title="Outgoing response" date="2021-09-08T16:42:02.393" type="response" statusCode="400" statusText="BadRequest" /><!-- duration: 24ms -->
  </step><!-- duration: 130ms -->
/home>
suwatch commented 3 years ago

@balag0 could you help? See if this dynamic function on Linux. If so, likely one need to set WEBSITE_RUN_FROM_PACKAGE to package uri instead of ZipDeploy (not supported).

balag0 commented 3 years ago

Looking at the template (and the kudu console screenshot which is not supported on dynamic) this error is from elastic premium app. Adding @sanchitmehta for the right repo for this issue.

offeka commented 2 years ago

Hey recently encountered this issue. @balag0 when trying to deploy Linux function app. Changing WEBSITE_RUN_FROM_PACKAGE to the package URL worked after finding this issue, but I couldn't find any documentation on that option. Adding to that the error message being bad request with no exception info also caused problems.

jvano commented 7 months ago

Hi

If the problem persists and is related to running it on Azure App Service, please open a support incident in Azure: https://learn.microsoft.com/en-us/azure/azure-portal/supportability/how-to-create-azure-support-request

This way we can better track and assist you on this case

Thanks,

Joaquin Vano Azure App Service