Automate deployment of Service Fabric project without TFS or VSTS - c#

I know you can publish a Service Fabric application written in C# using Visual Studio, and I have read this article on using TFS or VSTS to set up continuous integration DevOps builds of a Service Fabric application.
How can I just do this all manually using PowerShell? I know I can do the following using PowerShell from this article on deployment:
Use Visual Studio to package the project.
Transfer the package to a remote server.
Use the PowerShell script examples in the article to deploy the package while I am in the context of the remote server.
Instead, here are two bits I can't seem to figure out which would assist me in doing this from PowerShell:
Using PowerShell, how can I package my Service Fabric project the same way you can when you are in the context of Visual Studio?
Using PowerShell, how can I remotely deploy my Service Fabric project the same way you can when you are in the context of Visual Studio?

To generate the package through the command line, you can call the "Package" target on the sfproj file.
See my answer on create a deployment package for Service Fabric that includes all artifacts necessary to run the designed workflows at runtime
Then follow the instructions from https://azure.microsoft.com/en-us/documentation/articles/service-fabric-deploy-remove-applications/ as blackSphere suggested.

If you haven't seen this link, take a look at Deploy and Remove Packages using Powershell article.
Suppose you have a folder named MyApplicationType that contains the necessary application manifest, service manifests, and code/config/data packages. The Copy-ServiceFabricApplicationPackage command uploads the package to the cluster Image Store
That takes a directory and uploads it. Then you have to tell it to take that image and use it in the application.
The Register-ServiceFabricApplicationType command returns only after the system has successfully copied the application package. How long this takes depends on the contents of the application package. If needed, the -TimeoutSec parameter can be used to supply a longer timeout.
After you register it you can create the application:
You can instantiate an application by using any application type version that has been registered successfully through the New-ServiceFabricApplication command

Related

MSI installer for .Net 5 background service

I have a .Net 5 console application that I am trying to run as a Windows service. I have followed all of the articles online on how to do this and have it completed successfully (ie: using BackgroundService). The question is, I want to have an MSI installer to deploy this and all of the articles I have read about creating a service in .Net 5 instruct me to install the service manually using a command prompt or power shell and issuing the "sc" command.
Back before .Net 5, I could use the built in Visual Studio Installer extension and simply create an MSI that would deploy and install my service. I can't seem to make that work for .Net 5.
Is it still possible to use the built in Installer extension to deploy and install my .Net 5 BackgroundService?
Thanks!
Installing Services: There are many ways to install services, you should use an MSI package and the built-in mechanisms there to install and start the service and stop and update it during upgrades.
Various ways to install services (with links to samples on how to install services using MSI).
Learning WiX: Please see the WiX section here - the links should get you started. Direct link to the main WiX link list.
Links:
Windows Services Frequently Asked Questions (FAQ)
Installation package created with WIX Toolset does not remove program folder + files on uninstallation
How to install a system service without permission errors

Downloading a bot created on the portal leads to an invalid/unrunable solution

I went to the Azure Portal to try out the Bot Framework. I followed the steps and created a Proactive bot.
Without changing anything, I went to Configure continuous integration and downloaded the zip file.
When I try to open that SLN file in Visual Studio 2015 I get the following error when opening the solution:
The Output window shows this in the Solution dropdown:
Some of the properties associated with the solution could not be read.
Here's a screenshot of the Solution Explorer:
Then I press F5 to test it out...
Is it supposed to be running? Am I supposed to do something?
EDIT:
Locally debugging Azure Function apps (which is the type of application created by the Bot Service) is somewhat complex at this time. The process is also undergoing changes between the Azure SDK 2.9.6 and 3.0. The tooling for VS2017 is also undergoing some changes: .NET Web Development and Tools Blog
Update 3-10-2017: This preview copy of Azure Functions Tools does not
work with the newly released Azure SDK 3.0. If you want to continue
using these tools on Visual Studio 2015, you will need to remain on
the 2.9.6 SDK. Additionally, there are no Azure Function Tools
currently available for Visual Studio 2017. We are actively working
on the 2017 tools, and will provide an update in the next few weeks
regarding our plans and strategy.
This blog post by Benjamin Perkins has a nice walk through: https://blogs.msdn.microsoft.com/benjaminperkins/2016/12/01/how-i-tested-my-chatbot-that-i-created-using-the-bot-services-on-azure/
There's also this : Debugging Bots Built using Azure Bot Service on Windows
The C# environment in Azure Bot Service has more in common with
Node.js than a typical C# app because it requires a runtime host, much
like the Node engine. In Azure, the runtime is part of the hosting
environment in the cloud, but you’ll need to replicate that
environment locally on your desktop.
First, you need to set up your environment. You’ll need:
A local copy of your Azure Bot Service code (see Setting up Continuous Integration )
The Bot Framework Emulator
The Azure Functions CLI
DotNet CLI
and if you want breakpoint debugging in Visual Studio 15:
Visual Studio 15—the Community Edition will work fine
The Command Task Runner Visual Studio Extension
After installing the tools above, you have everything you need to
debug your C# bot locally.
Open a command prompt and navigate to the folder where your
project.json file lives in your repository. Issue the command dotnet
restore to restore the various packages referenced in your bot.
Note: Visual Studio 2017 RC is changing how it handles dependencies
from a project.json to a .csproj model when loading in Visual Studio.
As a result, you will need to download the csproj here:
https://aka.ms/bf-debug-project and save the .csproj into your
/repo/messages folder before running the dotnet restore command.
Note these are also requirements:
Azure 2.9.6 .NET SDK
Visual Studio Tools for Azure Functions
And there's this: https://blogs.msdn.microsoft.com/appserviceteam/2017/03/16/publishing-a-net-class-library-as-a-function-app/ you will find a description of how to publish a function app from visual studio, and how to download and execute an existing function app in visual studio.
Install the Azure Functions CLI from npm.
If you’ve installed the Visual Studio Tools for Azure Functions, just add func.exe to your path from %USERPROFILE%\AppData\Local\Azure.Functions.Cli\1.0.0-beta.93 (or the latest version on your machine).
Go to the Kudu console for your Function App in Function App Settings -> Kudu. Navigate to site and click on the download icon to the left of wwwroot (click on the animated gif below). Or, from an authenticated session, go to https://[YOURFUNCTIONAPP].scm.azurewebsites.net/api/zip/site/wwwroot/.
Unzip the file wwwroot.zip on your local machine. From that directory, run the following:
func azure login
func azure functionapp list
func azure functionapp fetch-app-settings [name]
This will create a local file called appsettings.json. These settings
are only used locally by the Functions CLI. Since this file contains
secrets, be sure not to check this file in to source control! (The
Azure Functions CLI adds appsettings.json to .gitignore for you.)
Copy your downloaded files to the web project folder (including
appsettings.json). Include the script files and function.json in the
project. F5 should now work and successfully attach a debugger.

Depoyment of pre-built Azure Web Service via PowerShell

I am completely new to Azure and PowerShell but have been tasked with setting up a build and deploy solution for several app services.
We currently have a build server (Azure VM) that is running CruiseControl.NET to build and test some C# .NET solutions that should be deployed in Azure.
This build server currently handles the following tasks:
Pulling code from source control when commits happen
Building the projects
Running some unit test cases
Copying output/binaries to an output location
However, as it exists now, developers of each of our app services need to 'Publish' their services manually from their development machines by clicking the button in Visual Studio once they have verified that the build and test cases have passed in the test environment on the server.
As I am hoping for a completely automated solution, I expect I need to use something like PowerShell or the Azure Cross Platform CLI (npm) to do this?
I'm extremely confused with the Azure Service Management vs Azure Resource Management versions with the new Azure Powershell 1.0. All of our services appear to be the newer Resource Management versions, not 'classic'.
The eventual goal is to have the build server do the following
Pulling code from source control when commits happen
Building the projects
Running some unit test cases
Copying output/binaries to an output location
If the build and test cases are successful, update the service in azure to the latest build
I am hoping there is a way to set up these projects, or take the existing binaries that result from the builds, and have them be deployed into Web Apps using the new Azure Resource Management Powershell features.
Any advice or resources for more information about how this can be done?
Hopefully this makes some sense. Please let me know if I am going about this completely the wrong way or direct me to a more correct forum.
Thanks!
have you consider to use Azure App Service? where you can get those build infrastructure for free. e.g https://azure.microsoft.com/en-us/documentation/articles/web-sites-publish-source-control/
Once you setup continues deployment, you will get below three when there is push event (if you are using git)
Pulling code from source control when commits happen
Building the projects
Copying output/binaries to an output location
and to "Running some unit test cases", you can create your own batch or powershell script with post deployment hook https://github.com/projectkudu/kudu/wiki/Post-Deployment-Action-Hooks

Which method should I use to execute an SSIS package remotely from a .net application?

I need to remotely execute an SSIS package located in the SSIS Package store from a C# .net application.
Application is located on a separate server, integration services cannot be installed on the app server.
I have the functionality working on my dev machine just using the file system method because I installed integration services to get it running. Now I need to flip it to call the package remotely.
Right now I'm using the following:
pkg = app.LoadFromDtsServer("\loadfile", "DBServer", Nothing)
But I get the following error:
"Connecting to the Integration Services service on the computer "DBServer" failed with the following error: "Access is denied." By default, only administrators have access to the Integration Services service. On Windows Vista and later, the process must be running with administrative privileges in order to connect to the Integration Services service. See the help topic for information on how to configure access to the service."
Certainly the user running this application in production will not be granted such rights on the database server. How can I make this run as a sql user? Is this the right way to go about this? There are other options, I know. The package does not absolutely have to be stored in the package store, but I believe this is best practice.
I should also mention that the application passes in a file name via a package variable, so any solution needs the ability to do that as well. I'm not sure how to do this if I create a job to run the package.
If you are passing parameters from the .NET application to the SSIS package, check the following link for options:
How to execute an SSIS package from .NET?
If no parameters are being passed, then an easier approach would be to add the SSIS package to a job and then call the job from the .NET application. The following link provides a code example:
http://www.roelvanlisdonk.nl/?p=1736
you can use stored procedures in the SSIS catalog to deploy the project and execute the packages
https://msdn.microsoft.com/en-US/library/jj820152.aspx?f=255&MSPPError=-2147217396

What is the best way of automating Windows Service deployment?

I have created a windows service using C# in Visual Studio 2010. I did a lot of research about automating the installation process. Got lots of advice but none did work for me. The windows service i have created has lots of dependencies and i would like client to have no UI interaction during the installation. I have created a setup project for this which includes all my dependencies within the installer.
Process involved:
Create a build for windows service
Push the setup file (.msi) to remote location
Call the .msi and install the service silently without user interaction.
What i did so far:
Created a powershell script to push files to remote location
Execute powershell script and install the service
Please keep in mind that powershell script
sc create "servicename" binpath="somepath"
is used for installing service from a project directory not for installing .msi file created using Setup Project these are two vast different things. If you don't understand this don't answer please.
Possible solutions:
Use (http://www.msbuildextensionpack.com/help/4.0.5.0/html/258a18b7-2cf7-330b-e6fe-8bc45db381b9.htm) msbuild extension pack.
Use buildarguments to call msbuild extension pack to install windows service.
Use (http://msdn.microsoft.com/en-us/library/x8zx72cd.aspx) Exec Task
Use WIX(Windows Installer Xml)
Now my question is. How can i push windows service installer to remote location? And how can create custom build arguments and use either msbuild extension pack or Exec Task and install the service?
I know this sounds stupid and irritating question for someone who hasn't installed the service using (.MSI) created by the Setup Project. But its my requirements which i am trying to solve since weeks in the enterprise environment.
I would do the bulk of the work from the powershell script.
Use the msbuild Exec task like you mentioned to add it to your build process. Here's a pretty good article on using the exec task to run your powershell script.
Since you are using VS 2010, a setup and deployment project is pretty easy. Add one to your solution, and add the output of your service project to it. Here's an article on adding the setup project for a windows service.
Use your powershell scripts to copy the installer .msi to the remote server. You can simply use copy-item [source] [destination] if you have access to the file share.
Stop the service on the remote machine. You can use (get-service -ComputerName [destination] -Name [service-name]).Stop() (from this question)
Install the service silently using psexec psexec \\remotecomputer "[msi-destination-path]" /qn Here's the rest of the command line options for the .msi.
Start the service using (get-service -ComputerName [destination] -Name [service-name]).Start()
I'd also add a bunch of parameters to the powershell script for destination server, service name, etc. It will make maintaining this part of your build process much easier. Your build agent will most likely have to be an administrator on the destination machine as well.
Lastly, make sure to put your powershell build script in source control!
Edit (June 2014)
VS 2013 has installer projects again! (Sorry, VS 2012)
Also, if found this awesome answer about how to install a Windows Service without using a setup project.

Categories