Jordi

Description

On my previous post I started to explain how to create a full CI/CD DevOps automated deployment cycle for your Smarterasp.net hosting websites defining the build pipeline implementation.

After creating a Build pipeline, we are going to finish it creating a release pipeline.

Requirements

You will need to fulfil some requirements first:

  • Previous post regarding build pipeline already done.
  • An SmarterAsp web hosting.

Steps to create a release pipeline

Check if the .NET version of your website is supported in smarterasp https://www.smarterasp.net/support/kb/a1986/supported-versions-of-_net-core.aspx
End of support versions normally are disabled, check here which version is already deprecated:
https://dotnet.microsoft.com/platform/support/policy/dotnet-core

Login to your smarterAsp.net hosting account control panel, go to [websites] tab. If there is no website already created, create one clicking [+New website] button and follow the steps, it is pretty straightforward.

After that you can expand your website settings clicking on [***] button on the right, you will have to check two main settings: Asp .NET Version and VS Webdeploy:smarterasp.net control panel

Check that your website has assigned the right pool type (ASP.NET 4.x Integrated):
smarterasp.net control panel pool manager

Check that your VS Webdeploy feature is enabled and copy: Service URL, Site/Application and  Username in a temporary place like your notepad, you will use them later (password is the same you use to enter Smarterasp.net control panel):smarterasp.net control panel web deploy

In Azure Devops check that your build pipeline generates the scripts to deploy your website using Web Deploy. Go to [Pipelines]-> Click on your [build pipeline name]-> Click on the [latest build]-> you will see a table where there is a row named [Related: 1 published(...)], click on 1 published:azure devops build artifact

You should be able to see a folder with a [xxx.cmd] file, some [xxx.xml] files and a [xxx.zip] file similar to this screenshot:azure devops build artifact files

After confirming that, you ensured you have the necessary files from your build pipeline, now let's start in Azure DevOps with the release pipeline work, open [Releases] tab in [Pipelines] section and click new release:azure devops releases

Select [Empty job] template:azure devops releases select template

If you don't plan to create a multi environment pipeline like [Development -> Staging -> Production]... just leave it with one basic environment: [Stage 1] and close this form:
azure devops releases default template

Add the artifact generated by your build pipeline, click [+Add]:
azure devops releases add artifact

Select the source (build pipeline) from this drop down and click [Add]:
azure devops releases add artifact select source

Set [continuous deployment trigger] to [Enabled] so every time a build is finished will trigger an automatic deployment:azure devops releases set continuous trigger

From the notepad details you saved before, create a new release variable for your password, click on [variables] and add: smarteraspPassword variable name, value, scope and save:azure devops releases set secret

Now, let's add some deployment tasks to [Stage 1] environment, click on [1 job, 0 tasks]:azure devops releases add tasts

Firs add two [RegEx Find & Replace task], in the search box type: replace, a specific task box will be shown, Add it two times:azure devops releases add replace task

Add a PowerShell task too:azure devops releases add PowerShell task

You should have 3 tasks added, let's configure the first one.
1) Add a meaningful name in Display name.
2) In Search Paths to Input Files field add: **\yoursite.deploy.cmd
    where you have to replace the bold part with the real name of the cmd file generated
    by your build release as you have seen before in the screenshot above.
3) In Find RegEx field add: _ArgComputerNameWithQuote\="%_ArgValue%"&goto
4) In Replace With field add: _ArgComputerNameWithQuote="https://yoursite:8172/
    msdeploy.axd?site=yoursite-001-site4"&goto

    where you have to replace the bold part with the real Service URL value you copied in
    notepad from SmarterAsp.net Web Deploy details before.

NOTE: SmarterAsp.net creates a self-signed certificate for the WebDeploy port 8172.azure devops releases add task settings

Let's configure the second Replace task.
1) Add a meaningful name in Display name.
2) In Search Paths to Input Files field add: **\yoursite.SetParameters.xml
    where you have to replace the bold part with the real name of the xml file in your build as
    you've seen before in the screenshot above.
3) In Find RegEx field add: \<setParameter name\="IIS Web Application Name"
     value\="Default Web Site" \/\>

4) In Replace With field add: <setParameter name="IIS Web Application Name"
    value="yoursiteapp" />

    where you have to replace the bold part with the real Site/Application value you copied in
    notepad from SmarterAsp.net Web Deploy details before.azure devops releases add task settings

Let's configure the last step, the powershell script to deploy your website.

1) Add a meaningful name in Display name.
2) In Script field add: your-file-path/yoursite.deploy.cmd /Y /M:hardcoded /U:your-user-001 /P:$(smarteraspPassword) /G:False /A:Basic -allowUntrusted -enableRule:AppOffline

    where you have to replace your-file-path with the real path of the xml file in your build as
    you've seen before in the screenshot above. (In my case was: 
    _mozcode.com-ASP.NET-CI/drop/Miniblog.Core.deploy.cmd)

    Replace your-user-001 with the real username as you've seen before in the
    screenshot.

   (Note: you are using the release password variable you declared before and getting it value
   in this way: $(smarteraspPassword) ).

3) Click [Save]and then click [Create Release]azure devops releases add task settings

You should be able to see a successful web deploy release in your pipeline log:azure devops successful release

If you see Error 500.34 in your browser after deploying your website and checking how it looks it happens because SmarterAsp.net is sharing your web application pool with another existing website and it won't work in this way. More info in these links:

https://www.smarterasp.net/support/kb/a1999/what-should-we-do-when-get-http-error-500_34-ancm-mixed-hosting-models-not-supported.aspx

https://weblog.west-wind.com/posts/2020/Jan/14/ASPNET-Core-IIS-InProcess-Hosting-Issues-in-NET-Core-31

To fix it, you have to add this line (AspNetCoreHostingModel one) in your .csproj file in all your smarterAsp.net websites deployed to that shared application pool and deploy them again:Http error 500.34 fix

And that's all folks!

 

Description

For personal, experimental, prototyping or small side projects lots of ASP.NET developers choose a cheap web hosting supplier like Smarterasp.net. If you are one of these developers using SmarterAsp.net for your projects nothing is stopping you to have a full CI/CD DevOps automated deployment cycle for your websites.

Traditionally the protocol to upload content to this kind of hosting plans is FTP or WebDeploy. Microsoft is offering a great DevOps free tool: Azure Devops. Setting it up is quite easy, just follow the steps after clicking [Start for free] button.

Once you have your Azure Devops project set, you will be able to configure and execute build and release pipelines for free targeting your Smarterasp.net web hosting plan.

Requirements

You will need to fulfil some requirements first:

  • Azure DevOps already set with an empty project.
  • An SmarterAsp web hosting.
  • A .NET website to deploy.

Steps to create a build pipeline

Start going to your Azure DevOps portal, select your project and click in Pipelines -> Pipelines -> [Create Pipeline]:

build-pepeline1.png


In this case, to simplify, we won't use a YAML. We well use the classic editor which you can convert to YAML later:

build-pepeline2.png


Select a repo:

build-pepeline3.png


Select the ASP.NET template:

1.png


You can see a new build pipeline with some pipeline tasks set by default. First, set your agent to Windows latest version (in this moment 2019):

2.png


Now set your nuget excutable to the latest version available (in this moment 5.x):

3.png


All tasks should work OK now with the other default configuration values. After this, click "Save & queue". Congratulations! you finalised the CI part, now you have a successful build pipeline:

Untitled.png


The next step is to create a release pipeline which will take the generated artifact and it will deploy it to your SmarterAsp.net hosting plan.

This is what is going to be described in the next article "part 2". Until then, enjoy!