Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a custom post deployment script to azure websites?

My problem is that I need to run a custom cmd file after the build. Instead of modifying the deployment scripts I just want to run few MSDOS commands to my deployment easily.

The task I need to do is to run a cmd at the repository located at /source/copyextrafiles.cmd after the build succeeded.

How can I achieve that?

like image 773
regisbsb Avatar asked Oct 13 '14 22:10

regisbsb


People also ask

How do I create a post deployment script?

To add and modify a pre- or post-deployment script Right click on the Scripts folder and select Add. Select Scripts in the context menu. Select Pre-Deployment Script or Post-Deployment Script. Optionally, specify a non-default name.

What is the recommended way to deploy a custom code solution in Azure?

Navigate to your app in the Azure portal and select Deployment Center under Deployment. Follow the instructions to select your repository and branch. This will configure a DevOps build and release pipeline to automatically build, tag, and deploy your container when new commits are pushed to your selected branch.

How do you automate deployment process in Azure?

To automate provisioning of Azure resources, you can use Terraform, Ansible, Chef, Puppet, Azure PowerShell, Azure CLI, or Azure Resource Manager templates. To configure VMs, you can use cloud-init (for Linux VMs) or Azure Automation State Configuration (DSC).

What is deployment script in azure?

These scripts can be used for performing custom steps such as: add users to a directory perform data plane operations, for example, copy blobs or seed database look up and validate a license key create a self-signed certificate create an object in Azure AD look up IP Address blocks from custom system The benefits of deployment script:

How do I deploy a script generator in azure?

Custom Deployment Script Generator. With Microsoft Azure Web Apps you can deploy your website by simply pushing your git repository, this will automatically deploy your website, and if you want to control this deployment flow you can use the custom deployment feature.

What can I do with custom scripts in Azure AD?

These scripts can be used for performing custom steps such as: add users to a directory perform data plane operations, for example, copy blobs or seed database look up and validate a license key create a self-signed certificate create an object in Azure AD look up IP Address blocks from custom system

How do I deploy my repository using Azure-CLI?

This script will copy all of the files from your repository to the wwwroot directory. But to make things easier, you can use the azure-cli tool which will actually generate a deployment script for you that will do exactly the same deployment process as the default one but now you are able to update that script and add (or remove) your own steps.


2 Answers

At the azure portal on the CONFIGURE tab of your website add a "app settings" entry called POST_DEPLOYMENT_ACTION with the value of source/copyextrafiles.cmd Save and the next deploy will run the cmd for you after the deploy.

Here the picture: enter image description here

like image 53
regisbsb Avatar answered Oct 20 '22 16:10

regisbsb


An alternative in addition to the solutions already provided is to copy the script in to a specific folder provided for post deployment action hooks.

So after creating a new directory in "D:\home\site\deployments\tools\" named "PostDeploymentActions", you could just add script files (.bat, .cmd or .ps1) into the directory and they will all run, one by one, after each deployment.

like image 25
Ole Kristian Losvik Avatar answered Oct 20 '22 15:10

Ole Kristian Losvik