When is a Azure Cloud Startup Task Executed? - azure

I have setup a startup task on my Azure Cloud Service for Web Role.
It executes a startup.cmd file which installs a third party S/W on cloud.
I have tested it on my local machine and it worked fine.
Now I have some questions about its execution on Azure Cloud Server:
Will startup task execute as soon as I publish my application on
server? Or I have to do something manually to get it executed.
How can I get information about execution of startup task? like it's
success, failure or is it executed or not? error messages and all.
Thank You

Answers to your questions from this link:
Will startup task execute as soon as I publish my application on
server? Or I have to do something manually to get it executed.
Yes. You don't have to manually trigger these startup tasks. Please see Role Startup Order section in the link for more details.
How can I get information about execution of startup task? like it's
success, failure or is it executed or not? error messages and all.
You can log the errors encountered during the execution of startup tasks in a directory specified by the TEMP environment variable. From the same link:
Your startup task can log information and errors to the directory
specified by the TEMP environment variable. During the startup task,
the TEMP environment variable resolves to the
C:\Resources\temp[guid].[rolename]\RoleTemp directory when running on
the cloud.
Startup tasks must end with an errorlevel (or exit code) of zero for
the startup process to complete. If a startup task ends with a
non-zero errorlevel, the role will not start.

Related

(Azure DevOps) Command Line Script .exe Console messages not visible in logs

I'm trying to run an .exe during a release pipeline on Azure DevOps.
In order to do so, I'm using a Command Line Script task where i just "invoke" the .exe file.
It works as it's correctly launched but i cannot see the output of the .exe (that is a .net framework 4.7.2 Console Application).
I've used a simple "Console.WriteLine()" method in the Console App in order to dump the messages. Obviously, on local machine it correctly writes messages on the console output. On Azure DevOps...just the Std Errors.
Why? How could I dump application messages to the task log?
Thanks
My bad. After different tries and retries i've found that the problem was related to a wrong dependency (resolved via reflection at runtime) that was causing exceptions before any log was written.
So, in fact, it works as expected.

IBM Notes Scheduled agent does not execute

I wrote an agent that runs every 1:00 AM daily, but fails to execute the routine mysteriously. I've checked the agent log and saw that it ran and ends without any error. What I've been thinking about is when I trigger the agent or ran it manually it executes the routine I coded successfully and not when it is scheduled. I really don't know what's the issue there, thanks for help in advance.
there are a few things to try
Check the trigger property on the agent and set it to run on All documents or change it to None. Test both scenarios. There are some issues with this setting.
When you run an agent manually from the notes client or designer you are running it using the credentials from you id file. When running it scheduled you use the credentials from the server.
Make sure your server have enough access to perform what your script does. There is also a setting in the agent for increasing what the script is allowed to perform.
If you have access to the server console you can trigger the agent to run on server using the command: tell amgr run "database.nsf" 'agentname'

Azure start-up task to run after the website is created

I've created a start-up task for an Azure website that does the following:
Creates an AppPool
Converts a Virtual Directory into a Virtual Application
I've created a powershell script that carries out these tasks.
I've set up the startup element in the Service Definition
<Startup>
<Task commandLine="MyStartup.cmd" executionContext="elevated" taskType="simple">
</Task>
</Startup>
All good so far.
However, I've found out, rather late, that:
IIS may not be fully configured during the startup task stage in the
startup process, so role-specific data may not be available.
I take this to mean that the website may not exist on IIS when the powershell script is run. I've tested the script and sure enough it fails because it can't find the virtual directory on IIS.
My question is: Is there a way to ensure the powershell script is run after the website is created on IIS?
Please note, I don't really want to use Microsoft.WindowsAzure.ServiceRuntime.RoleEntryPoint.OnStart if possible.
Thanks in advance.
I followed on from #kwill's suggestion and created the following:
Powershell:
while(!($myWeb = Get-Website -name "*MyWeb*")){
Write-Host "Website not installed. Waiting 30 seconds..."
Start-Sleep 30
}
# Proceed with installation
and configuration
<Task commandLine="MyBackground.cmd" executionContext="elevated" taskType="background">
</Task>
This works.
Check out the role architecture diagram at http://blogs.msdn.com/b/kwill/archive/2011/05/05/windows-azure-role-architecture.aspx. You can see that the startup tasks are executed before IISConfigurator creates the application pool for your website. This means that the only place you can make modifications to the apppool is in OnStart.
I haven't tried this, but you could create a background type startup task which will let the rest of the startup process (ie. running IISConfigurator) proceed while your startup task is still running, and then within that startup just loop until the virtual directory is detected.

How can I report an Azure startup failure to user

My company produces a tool that the user installs on the server prior to publishing their project. For Azure deployment we have a startup script (a simple .cmd file) that installs our tool. It has the recommended checks for repeat runs, and logs everything. The problem is that the user can't tell if there was an installation problem without RDPing to the role instance and checking the logs.
My question is: if there is a failure installing our tool is there any way to report it back to Visual Studio?
I don't believe there is. If I recall correctly, the startup tasks are fired off as part of the role's startup process (depending on the startup task type - simple, background, etc.). That script is running along with other things like the plug-in that configures Remote Desktop (which I believe the plug-in is a specially packaged type of startup script). I don't think there is anyway to report back (to whatever initiated the deployment operation) what startup tasks failed.

Application Azure will be Aborted when upload publish file with Startup task

I have created web application and one agent (EXE) with it fetch performance counter using WMI Query (compatible with 32 bit) so i have created one Enable32BitAppPool1.cmd file and add it in startup task, content of that file as per below
%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.enable32BitAppOnWin64:true
and set property of that file "Copy Always" as per following this link.
Now when i am going to upload that package to Azure then it will be Aborted or in Buzy mode
Can anyone please tell me the reason of this?
It seems your cmd file not working in startup task.
Two possible solution
1> Create .bat file and try in as a start up task for your webrole.
2> other solution is that, try to run the file (.cmd) using system.Diagostic.process.start(...) from some other exe file and set that exe file as a startup task.
There is absolutely no way to know, based on what you've posted, what's going on.
I'd enable remote desktop on that instance and check out the event logs to try and get a handle on what's happening.
If you can't remote desktop in because your startup task is killing it - then disable the startup task, remote desktop in, and try to run what you think the startup task is doing - but manually - so you can see what's actually going on.

Resources