How to reuse Azure startup tasks? - azure

I have an app which needs to be installed for all the services I have. Unfortunately, installation requires many files and task related input parameters (e.g. RoleInstanceValue xpath=...).
The way I came up with to share this task among cloud service projects is through Azure Plugins (here is a link to a library of them http://richorama.github.io/AzurePluginLibrary/).
The problems I see with this approach are:
It is not recommended/supported by Microsoft, which means they can
change support for that any time.
It requires copying files to C:\Program Files\Microsoft
SDKs\Azure\.NET SDK\v2.6\bin\plugins\NxlogAzureForwarder, adding an
extra step to build setup.
Microsoft recommends startup tasks. But I could not figure out a way to share them among cloud services.
So, my question is: how to easily reuse startup tasks?

As recommended your best chance would be a startup task that starts your app, which would be encapsulated into a Windows service. That service is going to be your reusable task/app/service (whatever you call it).
What you need extra is the following:
Project reference to your Windows service
An install script for the service
Installer tool
(Optional) app config for your service
To start your app/service you need to update cloud service definition by adding start up task and making runtime context elevated, and start your service in OnStart entry point.
That being said, you can place parameters of your app in the cloud config and read them in your WebRole and pass them to your service.
For more detail check out this post.

Related

Unnecessary Startup Command in Azure Pipelines for .NET Core Project

I've created a Linux App Service running .NET Core 2.2 on Azure. When I go to the deployment center and choose Azure-Repos/ Azure-Pipelines as the source control and then select my MVC Core repo, i'm required to enter a Startup Command, but deleting the command afterwards in the App Service's Configuration - General-Settings doesn't actually prevent the website from running?
Edit:
Actually, if I don't delete the Start-up command after deployment my app wouldn't run!
Well yes, AFAIK, it is true that the Startup command should be optional in the Deployment Center configuration blade, like it is in the Azure App Service Deploy task, unless it's needed for some other specific reason.
I shall check with our internal teams about this and get back with more details as I have them. Thanks for the question!
Update:
#jcmontx We have created a workitem to track and fix this. Please note that there are some other high priority changes planned for Linux Web App continuous delivery which will have effect on how startup command is handled. This means we will have first wait for these to complete before processing the requested change. Thanks for your patience!
I had the same problem. The only solution I found to this was to:
Add a random comment as Startup Command (your build may fail the first time) when setting up the Pipeline in the Deployment Center.
Then go to Azure Pipelines -> Releases -> Select YourPipeline -> Edit -> Tasks -> Select "Deploy Azure App Service"
Scroll down the options and you'll find "Startup command"
Remove your previous input (step 1)
Save

Different diagnostics.wadcfg file for each publish profile

As far as I know, regarding web-roles, it is possible to have multiple ServiceConfiguration.cscfg files, one for each publish profile (for example, Cloud1, Cloud2, Cloud3, Local and so on).
Though, is it possible to have different diagnostics.wadcfg (wadcfgx) files?
How to instruct Visual Studio to use a specific diagnostics file when deploying to Azure? Is there a specific entry in the publish profile XML file?
Out of the box, it is not possible because there can be only one diagnostics.wadcfg (wadcfgx) file associated with a role in a cloud project a cloud project.
We are using SDK 2.4 in our project and the way we have worked around this problem is by creating separate cloud projects for each environment - Dev, Staging, and Production. Since these are separate cloud projects, we can have different diagnostics configurations.
If you're using SDK 2.5, one thing that works in your favor is the diagnostics is now an extension (instead of plugin). What that allows you to do is change/enable/disable diagnostics on the fly. Though I have not tried it but one thing you could possibly do is enable diagnostics as a part of your deployment process. By default there won't be any diagnostics.wadcfgx file in your project. When you deploy your code via PowerShell, after successful deployment, you can enable this extension. Please see Step 4 here: http://azure.microsoft.com/en-in/documentation/articles/cloud-services-dotnet-diagnostics/#worker-role. (Since I have not tried it myself, I would be very much interested in knowing the outcome. Please do share if this approach worked for you).

Can a WebRole be "recycled" programmatically?

IIS7 application pools can be recycled programmatically. Is there an equivalent concept for the web role in Azure?
That is the basic question, but for background on why I ask, I include the following...
We are attempting to get Umbraco installed in Azure, and the Umbraco installation wizard writes it's configuration information and then manually restarts the application pool (in IIS) to reread the configuration it just wrote. It needs to work the same way in Azure, but at this point we are not able to get it to reinitialize itself from scratch (as it does in IIS7).
You can call RoleEnvironment.RequestRecycle() for a given role instance. This effectively has the Windows Server VM restart, which re-executes your startup scripts, OnStart() method, and Run() method. When doing this, you may want to consider some type of breadcrumb to leave yourself: If you find something installed upon restart, just skip the install process; otherwise, install and request a recycle.

Setup Project - Allow multiple installation of the same Windows Service

I have a question regarding to Setup Projects in .Net (c# language, Framework 4.0):
I made a setup project for a Windows Service, on the installation wizard, the user must input the name of the Windows Service as it would be installed. The setup program also creates a shortcut to the Uninstall program in case the user wants to remove that Windows Service.
The question is: how to let the user run the same setup program several times specifing different service name?
This behaviour could be required because the windows service is a socket consumer that connects to a server and retrieves data; to take advantage of the server capabilities the user could install the same windows service multiple times pointing to a different port on the server, to perform the data retrieving task much faster. The service is the same, the user just modify the port on the configuration file of the service, so that's why it's not logical to create a new version of the installer each time.
Any clue or suggestion would be appreciated, thanks in advance.
This can be done by using an multiple instances installation. The general approach is:
create a transform for each instance you want available to the user
use a custom EXE bootstrapper which applies a new transform to your MSI package each time a new instance is installed
The transform should change at least the PackageCode, ProductCode and UpgradeCode.
This is not supported by Visual Studio setup projects. So either you do it manually or use a commercial setup authoring tool which supports multiple instances.

SharePoint Solution Deployment: How do I prevent SP from resetting IIS when upgrading or retracting a globally deployed solutions?

So I figured out that by adding the ResetWebServer="FALSE" attribute to the solution manifest prevents SharePoint from recycling any app pools.
However, when upgrading a solution that originally did not specify ResetWebServer="FALSE" or when retracting a solution that does specify ResetWebServer="FALSE", the application pools are still being recycled. Is there a way to prevent any auto-recycling of app pools?
This does not seem possible given the document on MSDN (see below), note that I included Deploying a Solution over Upgrading a solution as underneath it is effectively doing a file replacement. I believe the restart/recycling is necessary as a result of how IIS functions. An option to explore if you wanted to manage when this occurs is to ensure that all deployments are done via timer jobs and execute when their impact will be minimized.
Deploying a solution
Initially, manifest and feature manifests are parsed to find assembly and _layouts files, which are copied to the appropriate locations. All other files contained within a feature directory are copied to the feature directory. After solution files are copied to the target computers, a configuration reset is scheduled for all front-end Web servers; the reset then deploys the files and restarts Microsoft Internet Information Services (IIS).
Retracting a solution
On each front-end Web server, the following occurs:
Microsoft Internet Information Services (IIS) is disabled.
Files are removed from the system.
IIS is re-enabled and Windows SharePoint Services is reloaded when
a user browses to a page.
You might also take a look at the "-local" switch. Didn't try it yet but it seemed that it allowed deployment server per server when you are in a load balanced situation.
Might be a good lead.

Resources