1
votes

I am trying - with no success - to run a post-deployment script on my webapp in Azure. I've created .sh and .cmd files, and placed them in site\deployments\tools\PostDeploymentActions, but the files don't run upon completion. All I'm trying to do is SSH into the deployment machine and run 1 line of code:

apt get install XXXX

I've tried looking at several other questions (How to add a custom post deployment script to azure websites?), but I can't re-create their success on my own machine.

It doesn't look like Azure has documentation on how to actually set up a post deployment action. And the only other resource I've found (https://github.com/projectkudu/kudu/wiki/Post-Deployment-Action-Hooks) hasn't given me success.

Has anybody else had success setting a post deployment action up? If so, can someone explain in very simple terms how to arrange it?

2

2 Answers

0
votes

Newest

Regarding this question, this Run Post Deployment Action works normally under both windows and linux. I have tried both of your posts. The answer below is running under windows, and the answer running under linux is in your other post.

In conclusion:

apt-get install xxx and pip install xxx are the environment variables for installing webapp. The Run Post Deployment Action on Azure mentioned in this article of yours. After testing, I found that azure is executed first during deployment deploy.sh file, and then execute my customized install_cmd.sh file.

The configuration of environment variables only needs to be configured once, and there is no need to execute each release. The specific test steps are in another post of yours.

enter image description here

enter image description here

After deploying application (that was easy with Ftp or Git) it would be nice to take some action. For example send an email, or write release notes to release page. I will do much fancier thing - I will write some text to console output.

For more details, you can refer the article(Azure post deployment scripts).

I tested it myself and it worked for me.

Step 1. Create .bat file under PostDeploymentActions folder.

enter image description here

Step 2. Open folder, check the status of deployment.

enter image description here

enter image description here

If you encounter issues, you can set SCM_COMMAND_IDLE_TIMEOUT and ACTIONS_ALLOW_UNSECURE_COMMANDS, you can go to google for details, if you have other issues, it is recommended to raise a support ticket on portal.

1
votes

Here is how you execute post-deployment scripts on an azure app service (tested with linux)

  1. Open your app service in azure portal
  2. Choose Configuration from the left hand menu
  3. Select General Settings
  4. Put a value in the Startup Command e.g. /home/site/deployments/tools/deploy.sh
  5. FTP into your app service and place your file in the path above

Now when you deploy your application, deploy.sh will be executed

Note: I took the existing startup command and placed it inside my custom deploy.sh

enter image description here