I have a Guest Executable that needs to access a shared drive (Azure Files). My guest executable is setup in of the ServiceManifest.xml. I've tried adding a to launch a "mysetup.bat" file that has the NET USE command that setups up the connection with my Azure Files share. However, I'm getting the following vague errors:
Error event: SourceId='System.Hosting', Property='CodePackageActivation:Code:SetupEntryPoint'. There was an error during CodePackage activation.The service host terminated with exit code:1
Anybody tried this before? Or at least any tips on how to get more information than the super helpful "Exit code:1"?
SetupEntryPoint is the right place to launch startup tasks. However, depending on what your startup tasks are you may need to specify a RunAsPolicy within the ApplicationManifest.xml.
Here is what I did:
Created a BAT file called 'setup.bat' and added it to my guest executable code folder. Inside this setup.bat file I am doing a NET USE statement to map a network drive to Azure Files share folder.
I added this:
<SetupEntryPoint>
<ExeHost>
<Program>setup.bat</Program>
<Arguments></Arguments>
</ExeHost>
</SetupEntryPoint>
to the ServiceManifest node.
<Policies>
<RunAsPolicy CodePackageRef="Code" UserRef="SetupAdminUser" EntryPointType="All" />
</Policies>
into the ServiceManifestImport node...
Then added the following
<Principals>
<Users>
<User Name="SetupAdminUser">
<MemberOf>
<SystemGroup Name="Administrators" />
</MemberOf>
</User>
</Users>
</Principals>
into the ApplicationManifest after the DefaultServices node. It's important that the Principals node comes after the DefaultServices node. Not sure why but it will make it impossible to deploy the application to your cluster.
In my case I solved the error: "CodePackageActivation:Code:SetupEntryPoint There was an error during CodePackage activation.The service host terminated with exit code:1"
by moving my setup script to a ps1 file and executing it from the MySetup.bat
So I ended it up with the following in my .bat and .ps1 files.
powershell.exe -ExecutionPolicy Bypass -Command ".\MySetup.ps1"
netsh http add urlacl url=http://erick1.com:80/ user="NT AUTHORITY\NETWORK SERVICE"
How to debug:
Remote Desktop your Virtual Machine and go to "D:\SvcFab_App[YOUR SERVCE TYPE NAME HERE]\log" and check the .err and .out files. Don't forget to add to your service manifest.. the entire section would be:
<SetupEntryPoint>
<ExeHost>
<Program>MySetup.bat</Program>
<WorkingFolder>CodePackage</WorkingFolder>
<ConsoleRedirection FileRetentionCount="10"/>
</ExeHost>
</SetupEntryPoint>
One last thing: In my case I had a special char in the .bat file that was not visible in Visual Studio and my setup was failing... I was only able to discovery it by reading the logs ( described above ). Don't be afraid of logs, it's usually one line in this case.
Thanks
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