问题
I have a Django web app on Azure. I'm using Azure's built in continuous deployment, so I don't have any .deployment files within my repo.
However, in order for my application to work correctly, I have to manually install a couple packages after that aren't available via pip. So after every deployment, I have to SSH into the deployment and execute the following 2 commands:
source home/site/wwwroot/pythonenv3.6/bin/activate
sudo apt-get install XXX XXX XXX
I believe I can simply execute this via a post deployment script, but am having a hard time finding any literature explaining exactly how to do so. Is utilizing a post deployment script the best way of doing this? I'd rather not manage a custom docker file if possible.
UPDATE Here is a screen shot of the packages installed after I manually run the apt-get command:
And here is a screen shot of the packages installed AFTER a re-deploy:
So unless there's a way to run this command from a post-deployment script (and have it execute correctly), my only option will be to create a custom container? I'm not wild about doing so considering that this is such a small customization... but I may no longer have a choice?
UPDATE I tried adding "apt-get install XXX XXX" to "PRE_BUILD_COMMAND" in Azure... and I got the following message as a result:
Are there any ideas how to get around this message using a prebuild or post build command?
回答1:
UPDATE
The command like below.
You must have the wrong path, just enter /home
, and then enter the command you want to execute, remember not to add sudo
.
PRIVIOUS
First of all, please check this post. The pyodbc in the post cannot be used. Later, I used apt-get install xxx
and pip install
to solve this problem.
I know you want to use the .sh
file, when you publish or re-publish, or when you publish for the first time, execute your apt-get install xxx
command.
But after my test, I can tell you that you only need to execute the command once after the portal creates the webapp, or after the first release, to configure the environment without having to execute the .sh
file again.
In conclusion:
It is recommended to execute commands such as apt-get install xxx
and pip install xxx
after the first release using git. Then modify the Readme.md
file on github to trigger the redeployment process.
You don’t need to execute the .sh
file for every deployment in the future. I replied to your other post. You can execute the .sh
file, but there is no need to call it every time after you execute it manually. Because this is a configurable environment variable, the configuration is successful.
Step 1. Install env.
Step 2. Modify readme.md,check deploy status.
we can see my custom .sh
command is running.But we no need to do that.
Step 3. Check the webapp after finishing env config .
来源:https://stackoverflow.com/questions/64887669/azure-post-deployment-script-commands