问题
I have an 'azure powershell task' running in my VSTS release after my 'deploy to azure site' task. In the powershell script, i have some transformations that i need to run on several of the files on the website, all based on the deployments variables.
The problem is I can't find the directory for the website. The root directory that the task is run under is something like:
D:\a_tasks\AzurePowerShell_71a1931a-effb-3d2e-8fd8-f7472a07cb62\3.1.18\
how do i point it to the d:\home\site\wwwroot\ , is there a build/release variable that automatically picks the deployment site location? Or can i just write out 'd:\home\site\wwwroot\' and expect that to not change in the future?
回答1:
thats not how it works (if I got you right). your script will run on your build\release agent, not on the webapp. You would need to use native kudu capability to achieve what you want to achieve: https://github.com/projectkudu/kudu/wiki/Custom-Deployment-Script
回答2:
I would suggest to use kudu
interface for both deploying the site and making transformations.
You could keep the code of both actions in your PowerShell
scripts. As a result, You will gain a lot of freedom in customization and boost extendability. It would be best if you attach them as build artifact / or repository reference.
If you add your automation scripts
as a package
you will bound version of deployment scripts with each release. It enables backwards compatibility (between deployment code - application code).
Pipeline definition example
来源:https://stackoverflow.com/questions/54160812/running-azure-powershell-script-on-web-app-during-release-task