Azure deployment from Azure DevOps failing to find zip package - azure

I am setting up a build and release pipeline for our Azure mobile app using Azure DevOps. I have completed the build and all works fine. I have a build task defined that creates the required zip file for deploying to Azure and this succeeds and the zip file is created at the root of the folder. But the deployment fails stating that the zip file cannot be found.
Here is my build task that creates the zip file.
And here is the output from the build step showing that it has successfully created the zip file.
But the deployment fails as it can't find the zip file.

You need to publish the .zip file from your build using the Publish Build Artifacts task. That will make it available as an artifact to be linked into a release definition to be deployed.

Related

Deploying a Vue app to Azure App Services with Azure Pipelines/releases

I'm trying to set up CI/CD with Azure pipelines to automatically deploy a frontend vue application, but am having trouble with deploying my frontend application from it.
When deploying manually from the VS Code IDE it works fine, with the /home/site/wwwroot looking as expected in the kudu file explorer:
However when it's deploying from Azure Pipelines, it seems that the zip file remains zipped and is stored in another directory within /home/site/wwwroot/Package (e.g /home/site/wwwroot/Client/.zip), resulting in the application being unable to
This is what it looks like in the kudu powershell debugger:
My pipeline and release is pretty standard. The steps are:
Uses Node 16.x
Downloads a .env file
Copies the .env file to the directory (/client) the application is in.
runs npm install
runs npm run build
archives the dist directory that is generated from the run build command
Publishes the archived dist folder as an artifact
An Azure release is then created and deploys the artifact to the correct Azure App Service. Currently the deployment method is set to default, although I have tried each of the different deployment methods (Web deploy, Zip deploy, and Run from package) but none have worked so far.
I've downloaded the resulting zip file from the pipeline deployment, unzipped and manually deployed (using VS Code) the dist folder within which was successful, so I'm quite sure that the pipeline part of the process which installs, builds, and packages the application is working as expected, but something is going wrong during deployment.
If anyone has any ideas of what the error may be, or is able to offer any help/sugestions, it would be greatly appreciated.
Thank you.
Ensure that the archive job option for "prepend root folder name to archive paths" is disabled in the pipeline.
Also ensure the Package or folder route in the release's deploy job is correct. It should be something like:
$(System.DefaultWorkingDirectory)/______ClientPipeline/ArtifactName/*zip

Where to save a reusable static jar to be used from an Azure DevOps pipeline?

I have an Azure DevOps pipeline
The pipeline has a "command line" task that runs a java command on a jar file
The jar file is a static one that represents a tool to be used in the build process.
The jar file is not created as part of the build pipeline. It's just a jar with one version and it doesn't change with each build
Where is the best place to save this jar file and how to download it to the agent during the build pipeline execution ?
Since the jar file is static one and not created as part of the build pipeline, you can save the jar file to Azure Artifacts Feed -> Universal Package.
To upload the jar file to Azure Artifacts Universal Package, you can use Universal Packages Task - Publish command in Pipeline or Azure CLI command: az artifacts universal publish (work in pipeline or local machine).
Then you can use the task: Universal Packages Task - Download command to download the Universal Package during the build pipeline execution.

Azure Devops - Build project, delete some files and zip a folder

I'm starting on Azure Devops.
With Azure Devops, how can I delete some files after the solution build and before generate a zip file, but all this in the same step?
In the image step, do the solution build and generate a zip with the package, ready to deploy, but I need delete some files inside this zip file.
MSBuild process print screen with arguments:
Zip file with all files to be deployed in the server and the zip that I need delete some files:
Maybe I will need unzip the package, delete the files and zip the package?
This MSBuild task will build project with MSBuild. And reviewing this doc: MSBuild Properties we find that currently there is no such argument implementing this feature.
In the meanwhile, we find this doc guides how to exclude Files and Folders from a Web Package.

How to output npm build error log files from linux hosted agents in vsts?

Trying to use the Linux build agents on vsts to build an angular application. For some reason it fails on the agent and I would like to get the full details in the log files. Any examples on how to get that sent to the output from the hosted build agents in vsts using a vsts build task?
To get the log files from Hosted agent, you just need to add Copy Files task and Publish Build Artifacts task in your build definition. Detail steps as below:
Add Copy Files task after the task you failed
After the task you failed (as the failed log you showed), add Copy Files task with below settings:
Add Publish Build Artifacts task after Copy Files task
The Publish Build Artifacts task settings as below:
Queue the build agent again
After the build finished, download the build artifacts to get the log files:

Deploy the Gulp Build Folder To Azure from Visual Studio Team Services

I just started using VSO for one of my project. I have created the built definition and the built was successful. When I tried to create the release definition for that built its failing by throwing the error
System.Management.Automation.RuntimeException: No files were found to deploy with search pattern C:\a\858bddd5b\**\*.zip
Its expecting .zip files. Since I need to deploy the distributed folder created by gulp build, I have given the Web Deploy Package path as
$(System.DefaultWorkingDirectory)/{built name}
Any help is really appreciated
You should add a build step to create an archive with .zip extension for the output folder of the gulp step. Your steps should look like
VSO/VSTS build has a task available with Archive files to achieve the same.
Alternatively, if the standard Archive files step doesn't work for you, you can use a powershell step. The powershell command will look like the following.
[io.compression.zipfile]::CreateFromDirectory($Source, $Destination)
Source should be all the files/folders from gulp output you wish to deploy
Destination here should correspond to input for the webdeploy/ WebApp deployment step.
You can also use this extension to create a ZIP file. I used it for a situation similar to yours:
https://marketplace.visualstudio.com/items?itemName=trackyon.trackyonadvantage
"Azure Web App Deployment" task requires a web deploy zip package. You can either add one more task to create a zip package for the build output as other two answers indicated or add some code in your "gulpfile.js" to generate a zip package during the gulp build and then publish the zip package to artifact.
If you don't want to create a zip package for the build output, then you can use FTP Uploader task to deploy the build to Azure Web App via FTP Deploy.
You can create a zip file with PowerShell, assuming you're running on a Windows agent.
Command Line task
Command: powershell
Arguments: -Command "&{Add-Type -assembly 'system.io.compression.filesystem'; [io.compression.zipfile]::CreateFromDirectory('$(Build.StagingDirectory)\Zip', '$(Build.StagingDirectory)\$(BuildConfiguration)Deploy.zip')}"
Obviously, replace $(Build.StagingDirectory)\Zip with whatever folder you want zipped up and $(Build.StagingDirectory)\$(BuildConfiguration)Deploy.zip with whatever you want the file named.

Resources