{"id":225104,"date":"2017-08-30T22:59:36","date_gmt":"2017-08-31T05:59:36","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=225104"},"modified":"2019-05-01T23:12:31","modified_gmt":"2019-05-02T06:12:31","slug":"create-a-cicd-pipeline-to-azure-service-fabric","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/create-a-cicd-pipeline-to-azure-service-fabric\/","title":{"rendered":"Create a CI\/CD pipeline to Azure Service Fabric"},"content":{"rendered":"<p>At \/\/BUILD 2017, we shipped an update to the <a href=\"http:\/\/aka.ms\/CD4VS\">Continuous Delivery Tools for Visual Studio<\/a>. This update has support for configuring a Continuous Integration and Continuous Delivery pipeline for <a href=\"https:\/\/docs.microsoft.com\/en-us\/aspnet\/core\/\">ASP.NET Core<\/a> projects with <a href=\"https:\/\/www.docker.com\/what-container\">container support<\/a> to an existing <a href=\"https:\/\/azure.microsoft.com\/en-us\/services\/service-fabric\/\">Azure Service Fabric cluster<\/a> directly from <a href=\"https:\/\/www.visualstudio.com\/downloads\/\">Visual Studio 2017<\/a>.<\/p>\n<p>To configure continuous delivery to a Service Fabric cluster, first you need <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/service-fabric\/service-fabric-tutorial-create-cluster-azure-ps\">to create a preview version Service Fabric cluster<\/a>. Start by creating a security certificate to secure administrative access to the cluster. Open a PowerShell console, login to Azure and select the Azure subscription that you want to deploy the cluster in then create and encrypt a password for the certificate used by Service Fabric to secure access to your cluster by running the following commands:<\/p>\n<div>\n<pre class=\"lang:default decode:true \">Login-AzureRmAccount\r\n\r\nSelect-AzureRmSubscription -SubscriptionId &lt;subscription-id&gt;\r\n\r\n$pwd = \"&lt;your password&gt;\" | ConvertTo-SecureString -AsPlainText -Force<\/pre>\n<p>Keep your PowerShell console running and download the <a href=\"https:\/\/aka.ms\/securepreviewonelineclustertemplate\">Azure Resource Management Template for Service Fabric<\/a> azuredeploy.json and the sample azuredeploy.parameters.json locally. Edit the parameters file to name, size and secure your cluster as well as set its location. Ensure that the <i>clusterCodeVersion<\/i> is set to the preview version <b>255.255.5718.255<\/b>. Once your configuration files are ready, create the cluster by running the following commands:<\/p>\n<\/div>\n<div>\n<pre class=\"lang:default decode:true \">New-AzureRmServiceFabricCluster\r\n\r\n -TemplateFile C:\\&lt;your_working_folder&gt;\\azuredeploy.json `\r\n\r\n -ParameterFile C:\\&lt;your_working_folder&gt;\\azuredeploy.parameters.json `\r\n\r\n -CertificateOutputFolder C:\\&lt;your_working_folder&gt;\\ `\r\n\r\n -CertificatePassword $pwd `\r\n\r\n -CertificateSubjectName \"&lt;your_cluster_name&gt;.&lt;cluster_location&gt;.cloudapp.azure.com\" `\r\n\r\n -ResourceGroupName &lt;your_cluster_RGname&gt;<\/pre>\n<p>Once the Service Fabric creation is completed, the command will output cluster information to the console window and copy the security certificate to your working folder. Double click on the certificate to import it to the current user certificate store. Remember to <b>mark the certificate key as exportable<\/b> in the private key protection step and complete the import wizard. This will allow the Configure Continuous Delivery experience to export the key while configuring your release definition.<\/p>\n<\/div>\n<p>With a preview version of the Service Fabric Cluster, you can now configure Continuous Delivery from Visual Studio 2017 with the latest version of the Continuous Delivery Tools for Visual Studio extension. Create or open an existing solution with an ASP.NET or ASP.NET Core project. Add Docker support to the project and ensure that the solution is under version control on VSTS or GitHub. Right click on the solution in Solution Explorer and select Configure Continuous Delivery.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225102\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/04\/CICD-pipeline-for-Azure-Service-Fabric-Select-Configure-Continuous-Delivery-in-Solution-Explorer-Cropped.png\" alt=\"\" width=\"1410\" height=\"746\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/04\/CICD-pipeline-for-Azure-Service-Fabric-Select-Configure-Continuous-Delivery-in-Solution-Explorer-Cropped.png 1410w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/04\/CICD-pipeline-for-Azure-Service-Fabric-Select-Configure-Continuous-Delivery-in-Solution-Explorer-Cropped-300x159.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/04\/CICD-pipeline-for-Azure-Service-Fabric-Select-Configure-Continuous-Delivery-in-Solution-Explorer-Cropped-768x406.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/04\/CICD-pipeline-for-Azure-Service-Fabric-Select-Configure-Continuous-Delivery-in-Solution-Explorer-Cropped-1024x542.png 1024w\" sizes=\"(max-width: 1410px) 100vw, 1410px\" \/><\/p>\n<p>With Service Fabric Cluster as the Target Host type, select your newly created Serviced Fabric cluster to act as a target for continuous delivery.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-225103\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/04\/CICD-pipeline-for-Azure-Service-Fabric-Configure-Continuous-Delivery-Dialog.png\" alt=\"\" width=\"1625\" height=\"1006\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/04\/CICD-pipeline-for-Azure-Service-Fabric-Configure-Continuous-Delivery-Dialog.png 1625w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/04\/CICD-pipeline-for-Azure-Service-Fabric-Configure-Continuous-Delivery-Dialog-300x186.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/04\/CICD-pipeline-for-Azure-Service-Fabric-Configure-Continuous-Delivery-Dialog-768x475.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2019\/04\/CICD-pipeline-for-Azure-Service-Fabric-Configure-Continuous-Delivery-Dialog-1024x634.png 1024w\" sizes=\"(max-width: 1625px) 100vw, 1625px\" \/><\/p>\n<p>Visual Studio will automatically pick up the cluster certificate from your user certificate store and verify the thumbprint. Enter the password for the certificate and select your Azure Container Registry then click OK. Once the configure continuous delivery completes, you will have a configured build and release pipeline for your project to your new Service Fabric Cluster.<\/p>\n<p>To expose your web service outside its container you need to enable port mapping for your container by modifying the docker-compose.yml file for that project to enable the port mapping for your service. If you have multiple services, you need to do that for each of them.<\/p>\n<pre class=\"lang:default decode:true \">version: '3'\r\n\r\nservices:\r\n  &lt;your_service_name&gt;:\r\n    image: &lt;your_image_name&gt;\r\n    ports:\r\n    -\t\u201c80:80\u201d\r\n    build:\r\n      context: .\/&lt;your_service_context&gt;\r\n      dockerfile: Dockerfile<\/pre>\n<p>To expose these services outside the Service Fabric Cluster, you need to configure your load balancer to do so for each service port. By default, the current sample ARM template and parameter files load balance traffic on port 80 and 8081 for the cluster. If you need to configure other ports you can do so by adding new entries in your ARM template<\/p>\n<pre>\"loadBalancedAppPort1\": {\r\n      \"type\": \"int\",\r\n      \"defaultValue\": 80,\r\n      \"metadata\": {\r\n        \"description\": \"Input endpoint1 for the application to use. Replace it with what your application uses\"\r\n      }\r\n<\/pre>\n<p>and modifying the values in your parameters file.<\/p>\n<pre>\"loadBalancedAppPort1\": {\r\n      \"value\": 80\r\n    },\r\n    \"loadBalancedAppPort2\": {\r\n      \"value\": 8081\r\n    },\r\n<\/pre>\n<h2>Please keep the feedback coming!<\/h2>\n<p>Thank you to everyone who has reached out and shared feedback and ideas so far. We\u2019re always looking for feedback on where to take this <a href=\"https:\/\/blogs.msdn.microsoft.com\/somasegar\/2013\/02\/19\/the-evolution-of-devlabs\/\">Microsoft DevLabs extension<\/a> next. There\u2019s a <a>Slack channel<\/a> and a team alias <a>vsdevops@microsoft.com<\/a> where you can reach out to the team and others in the community sharing ideas on this topic.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At \/\/BUILD 2017, we shipped an update to the Continuous Delivery Tools for Visual Studio. This update has support for configuring a Continuous Integration and Continuous Delivery pipeline for ASP.NET Core projects with container support to an existing Azure Service Fabric cluster directly from Visual Studio 2017. To configure continuous delivery to a Service Fabric [&hellip;]<\/p>\n","protected":false},"author":3453,"featured_media":255385,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1388,155],"tags":[1396,454,1354],"class_list":["post-225104","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-extensibility","category-visual-studio","tag-azure-devops","tag-cicd","tag-devtest-labs"],"acf":[],"blog_post_summary":"<p>At \/\/BUILD 2017, we shipped an update to the Continuous Delivery Tools for Visual Studio. This update has support for configuring a Continuous Integration and Continuous Delivery pipeline for ASP.NET Core projects with container support to an existing Azure Service Fabric cluster directly from Visual Studio 2017. To configure continuous delivery to a Service Fabric [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/225104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/3453"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=225104"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/225104\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/255385"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=225104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=225104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=225104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}