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?
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.
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.
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).
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:
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.
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
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.
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With