Azure Cloud Service Startup task that needs to run a PowerShell script -


all,

note: have updated question after feedback.

thanks @jisaak far.

i have need run powershell script adds tcp bindings , other stuff when deploy cloud service.

here cloud service project:

enter image description here

here cloud service project , webrole project: enter image description here

here task in servicedefinition.csdef:enter image description here

and here powershell script want run: enter image description here

here attempt @ startup.cmd: enter image description here

when deploy in azure log: enter image description here

and in powershell log: enter image description here

any appreciated.

i think there following other people syntax on web doesn't seem me there.

thanks russ

i think issue working directory of batch command interpreter when runs startup.cmd runs not expected.

the startup.cmd located in \approot\bin\startup directory working directory \approot\bin.

therefore command .\rolestartup.ps1 not able find rolestartup.ps1 looking in bin directory not in bin\startup directory.

solutions know are:

solution 1: use ..\startup\rolestartup.ps1 call rolestartup.ps1 startup.cmd.

soltuion 2: change current working directory in startup.cmd relative path .\rolestartup.ps1 found. chdir %~dp0 (see here) change directory contains startup.cmd.

solution 3: don lockhart's answer suggested, not copy startup directory output, instead leave set "content" in visual studio project. means files within exist in \approot\startup directory on azure instance. (you want make sure startup folder not publically accessible via iis!). update reference startup.cmd in servicedefinition.csdef ..\startup\startup.cmd, , update reference rolestartup.ps1 in startup.cmd ..\startup\rolestartup.ps1. works on fact working directory bin , uses ..\startup locate startup directory relative it.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -