This documentation says its possible to deploy a zip file to an API app.
However what should be zipped up isn't detailed? Is it the full project folder? or is it only the published application?
I've tried deploying many sample API applications from here - https://github.com/aspnet/Docs/tree/master/aspnetcore. None of them appear to show and no logs appear for any of these either. Would be nice to know what to put in the zip file before pushing to an App Service.
Steps to reproduce:
This works locally with dotnet core 2.1, however when deploying to the Azure API service I don't get a response.
Problem:
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@rbhadti94, Thank you for your feedback!
As mentioned in the same document, ‘If you downloaded the files in a ZIP file, extract the files first. For example, if you downloaded a ZIP file from GitHub, you cannot deploy that file as-is. GitHub adds additional nested directories, which do not work with App Service.’ Kindly ensure that all the files are extracted.
You need to create a ZIP archive of everything in your project. This directory should contain the entry file to your web app, such as index.html, index.php, and app.js. It can also contain package management files - like project.json, composer.json, package.json, bower.json, and requirements.txt.
Also, ensure that there is a default page appropriately set in the project root folder. To fetch more details on the error, you could also enable Application Event Log, checkout the document for more details: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/azure-apps/troubleshoot?view=aspnetcore-2.2#troubleshoot-app-startup-errors
I see that you have already closed this issue, If there are further questions regarding this matter, please reopen it and we will gladly continue the discussion.
Hi @AjayKumar-MSFT - Thanks for the response.
I wasn't using the Github repository directly. I went into the sample app root folder when running all my commands.
It actually turns out that I was restoring/publishing/zipping the sample app (linked in my original issue) using the following commands:
dotnet restore
dotnet publish -o ./myapp
zip -r myapp.zip ./myapp/*
## Then deploy this zip to the Azure API App Service
However this fails for the API app service because the Azure API App service runs natively off a Windows based App service plan. And by defaultdotnet publish
produces an app for a linux target system. Hence deploying this zip file to the app service will fail.
The solution is to do:
dotnet restore
dotnet publish -o ./myapp --runtime win-x64
zip -r myapp.zip ./myapp/*
## Then deploy this zip to the Azure API App Service
Note the --runtime win-x64
extra args when publishing. This way the published binaries match the target platform.
I'm aware that different App services come with different plan types (Windows or Linux plan types). It should probably be made clear that when publishing, the correct runtime has to be targeted.
I'll have a trawl through the existing documentation to see if it can be added in anywhere. At the moment the section Create a project ZIP file is a bit too vague. Because for different languages/frameworks (Java, .NET Core, .NET Framework etc...) the contents to zip will be different.
@rbhadti94, Thank you for your detailed feedback and sharing the solution that worked for you. Your feedback has been shared with the content owner (@cephalin) for further review.
Thanks @AjayKumar-MSFT.
@rbhadti94 and @AjayKumar-MSFT, I'm facing the same issue. I have a PHP site. When I deploy it using powershell. It gets deployed successfully but doesn't display anything on the page.
M I doing something wrong while deploying or do I need to follow any step post doing a Zip deploy using Invoke-RestMethod.
@vatsparth, Invoke-RestMethod request triggers push deployment from the uploaded .zip file. So, ensure that all the deployment files including the default document are available in site/wwwroot folder. You may navigate to Kudu Console (https://yourwebsite.scm.azurewebsites.net/) to review the files.
@AjayKumar-MSFT Yeah, I can see all the files present there via Kudu console. But I'm still not able to see anything up on the web page. Do we have any further steps post this.
@vatsparth, Could you please send an email to AzCommunity[at]Microsoft[dot]com referencing this GitHub issue and your Azure subscription ID, we would like to work closer with you on this matter.
@AjayKumar-MSFT,
Thanks, Sure will do that. But before that I just wanted to make sure. Does it work the same way for docker based Web Apps?
@vatsparth, If your question is specifically about the build requirements - With continuous deployment, you can get your app up and running on Azure directly from source code. No external build or publication process is required. However, there is a limit to the customizability and availability of build tools within the Kudu deployment engine. Your app may outgrow Kudu's capabilities as it grows in its dependencies or requirements for custom build logic. Checkout this document for more details on this topic. Kindly let us know if you need any further help.
@vatsparth - For Docker based web apps, the image should be self-contained. i.e. your Docker entrypoint needs to call/run an executable which can run the web application. E.g.
ENTRYPOINT[ "ng serve"] #Angular
ENTRYPOINT["dotnet <somedll>.dll"] #Dotnet
ENTRYPOINT["java -jar <myapp>.jar"] #Java
@rbhadti94 A few comments:
dotnet publish
is not in the scope of App Service documentation, so I think it's appropriate to doc this caveat in our doc set.Hi @cephalin ,
Thanks for the reply. I agree for development environments and for prototyping this is ideal.
I'm talking from the perspective of higher environments (higher than dev). I'm aware that we can set SCM_DO_BUILD_DURING_DEPLOYMENT=true
but from my experience most are unlikely to deploy directly to higher environments from source control (or from Visual Studio).
I could be wrong but deploying a package is a much more common method which can be controlled/audited etc... and its worth having instructions for that (for every technology) somewhere in the docs.
@rbhadti94 Thanks for offering your feedback. We'll consider this for our documentation updates. For now I'm going to close this issue. #please-close