Category Archives: Visual Studio

Azure and Let’s Encrypt certificate

In this post I will show you how to

  1. Create a sample .net core 3.0 website.
  2. Deploy a website to an Azure App Service.
  3. Assign a custom domain.
  4. Enable Let’s Encrypt certificate

Create a sample .net core 3.0 website

Startup Visual Studio 2019 and create a new project. Choose “ASP.NET Core Web Application” as your project template.

Create new ASP.NET Core web application

Press Create. Then choose “Web Application” .

Create an empty web application

Pres Create and Visual Studio opens with an overview screen of your new ASP.NET Core application. Press F5 to see it in action.

Now it is time to publish (or deploy) your (skeleton) application to Azure.

Deploy website to Azure

Deploying your website to Azure is simple. Right click on the solution and select Publish. Make sure App Service and Create New is selected and press Create Profile.

Publish a website to Azure

Now we have to fill in the details for the App Service. Please fill out the screen as you see fit.

Create a new App Service

Press Create and wait for the App Service to be created (this could take a while). When the window closes the App Service is created. Now it is time to publish the website to this app service. Press Publish

After a few moments the website is published and visual studio will start a new browser and open the website from the Azure environment.

As you can see the site has a domain name of “frubelen.azurewebsites.net”. Now it is time to assign our custom domain name to this site. After doing this we can send our browser to azure.frubelen.nl (for example) instead of the azure domain.

Assign a custom domain

Now we are going to assing our custom domain name. First of all you will have to decide if you want to assign the domain to the azure website or a subdomain.

If you want to assign the entire domain (not a subdomain) to this azure site you will have to create an A record at your dns provider. If you only want this azure site for a subdomain you should create a alias record, a CNAME record.

I have choosen to only send the subdomain azure.frubelen.nl to this site so I create a CNAME record at my DNS provider:

Create a CNAME record if you want to redirect a subdomain to azure

After changing your DNS registration it takes some time before all DNS servers have received this change. To check if DNS servers have received the change you could send your browser to https://digwebinterface.com/

Now go back to the azure portal and navigate to your App Service and select Custom Domains.

Press on “Add custom domain”. Fill in your subdomain to redirect to azure. In my example it is “azure.frubelen.nl”. Press Validate to let Azure retrieve the DNS records for the domain.

If the DNS servers are updated Azure will let you add the domain; press “Add custom domain”.

As you can see the domain is added. The next step is to secure our domain with a Let’s Encrypt certificate.

Enable Let’s Encrypt certificate

Now it is time to add the Let’s encrypt certificate to our domain. First of all you need a storage account. Let’s encrypt stores it certificate information on this storage account. Go to your resource group (mine is FRUBEL_RG) and press Add. Type “Storage account” and select the item from the dropdown. Press create. Type in a storage account name ( I will use letsencryptfrubelen). Press “Review and create” press “Create”.

Next navigate to the storage account just created and selected the keys “Access Keys” page.

Copy the connectionstring for Key you will need this later on. Now in the Azure portal go back to your App Service and select Configuration on the left navigation.

Now we are going to add 2 app settings to the app service. Both have as value the connection string to the storage account. Add the key AzureWebJobsStorage and AzureWebJobsDashboard.

First create a new App Registration. Select “Azure Active Directory”.

The select App Registration in the navigation on the left and then press “New Registration”.

Press Register. On the overview screen press “Add an application ID URI”. Then press “Add a scope”. Remove the default and fill in (in my case) “http://frubelen” and press “Save and Continue”.

Fill out the next screen as shown below and press Add Scope.

First, you need to install the Azure PowerShell module, which can be done though WebPI or the PowerShell Gallery.

Execute the Powershell commands below. It will create an App Registration in your Azure Active directory.

As you can see the site has a domain name of “frubelen.azurewebsites.net”. Now it is time to assign our custom domain name to this site. After doing this we can send our browser to azure.frubelen.nl (for example) instead of the azure domain.

Assign a custom domain

Now we are going to assing our custom domain name. First of all you will have to decide if you want to assign the domain to the azure website or a subdomain.

If you want to assign the entire domain (not a subdomain) to this azure site you will have to create an A record at your dns provider. If you only want this azure site for a subdomain you should create a alias record, a CNAME record.

I have choosen to only send the subdomain azure.frubelen.nl to this site so I create a CNAME record at my DNS provider:

Create a CNAME record if you want to redirect a subdomain to azure

After changing your DNS registration it takes some time before all DNS servers have received this change. To check if DNS servers have received the change you could send your browser to https://digwebinterface.com/

Now go back to the azure portal and navigate to your App Service and select Custom Domains.

Press on “Add custom domain”. Fill in your subdomain to redirect to azure. In my example it is “azure.frubelen.nl”. Press Validate to let Azure retrieve the DNS records for the domain.

If the DNS servers are updated Azure will let you add the domain; press “Add custom domain”.

As you can see the domain is added. The next step is to secure our domain with a Let’s Encrypt certificate.

Enable Let’s Encrypt certificate

Now it is time to add the Let’s encrypt certificate to our domain. First of all you need a storage account. Let’s encrypt stores it certificate information on this storage account. Go to your resource group (mine is FRUBEL_RG) and press Add. Type “Storage account” and select the item from the dropdown. Press create. Type in a storage account name ( I will use letsencryptfrubelen). Press “Review and create” press “Create”.

Next navigate to the storage account just created and selected the keys “Access Keys” page.

Copy the connectionstring for Key you will need this later on. Now in the Azure portal go back to your App Service and select Configuration on the left navigation.

Now we are going to add 2 app settings to the app service. Both have as value the connection string to the storage account. Add the key AzureWebJobsStorage and AzureWebJobsDashboard.

First, you need to install the Azure PowerShell module, which can be done though WebPI or the PowerShell Gallery.

Execute the Powershell commands below. It will create an App Registration in your Azure Active directory.

The commands above create an App Registration in the Azure Active Directory.

Next go to the App service and select Extensions in the left navigation. Add the Let’s encrypt extension. Press Add and search for “”

Select the Legal Terms item, press Ok and next press Ok to add the extension. Then select the Extension and press Browse. A new browser window will open in which you van configure Let’s encrypt.

Go to your App Service and select Configuration on the left navigation.

Add the following App Settings

letsencrypt:Tenant The name of the directory you are working in
letsencrypt:SubscriptionId The id of your subscription
letsencrypt:ResourceGroupName The name of the resource group
letsencrypt:ClientId This is the ApplicationId of the app service (in the powershell $app.ApplicationId)
letsencrypt:ClientSecret The password (clear text)

Now go to the extensions page of the App Service and select Let’s Encrypt

In the screen that opens press Browse.

Fill in connection strings for the storage account and press Next.

Press Next.

Select the domain you want a certificate for, fill in your email and press “Request and install certificate”.

Your certificate is requested and installed. Now open a browser and navigate to https://azure.frubelen.nl. There you go your site is secured with a SSL certificate.

Share

Test a WCF service with SOAPUI

With help of SOAP UI you can easily test your webservices. In this pos tI’m going to test a WCF web service (yes MS WCF; not my favourite company and technology but anyway….)

First create your webservice. Within Visual Studio goto File -> New Project . Choose Visual C# and select  WCF Service Application

Create new project

Now start your project by pressing F5; the service, together with the WCF Test Client, will start and there are two methods available on this service:

GetData and  GetDataUsingDataContract

The WCF Test client

Play around with the WCF Test Client to get the idea of how this works. Next we will install SOAP UI. Download your copy here. Install SOAP UI using the default settings.

After installation start SOAP UI and create a new project. Goto File -> New soapui Project . Fill out the dialog as shown below (don’t forget to add the ?wsdl ):

 Press Ok; a new soapui project will be created. See the image below:

Now you can execute the same request as the WCF Test Client did; but there is more; much more!

Right click on the WCFTestService1 and choose New TestSuite.

Press OK. Right click on TestSuite 1 and choose New TestCase:

Press OK. Right click on Test Steps choose Add step and then Test request.

Press OK. Choose the operation you want to test:

Press OK. On the next screen leave things as suggested

Press OK. Your first test request is added to the TestCase.  By double clicking the TestCase 1 item and pressing the play button the test will be excuted. As you expected the test will succeed and a green icon is shown right before the test request entry:

Now lets add some testdata to the request. Place the following XML in the test request XML window. First select the xml view:

Now paste the XML below into the request:

Now you can add assertions to your test script to make sure the operations works the way you want. For example lets assert that the GetDataResult field contains the text “You entered: 3”. Press the plus sign next to the play button:

Select the SOAP response assertion:

Give the assertiona unique name:

Type the text you want to look for in the response.

Now if you execute the request it will still succeed because the request contains the number three. Change this number to, for example 4, and you will see that the assertion fails.

Share

Working with Visual Studio 2010 and github on Synology

gitInstall the  "GIT server"  package on your Synology Disk Station. Goto the package center and search for the “Git Server” package. Download and install it.

Install GitExtensions on your dev box.

Install the latest msysgit on your dev box.

Install the  "Git Source Control Provider"  Visual Studio 2010 extension on your dev box. In Visual Studio goto Tools -> Extensions and search for “Git Source Control Provider” in the online gallery.

Now SSH to your Synology (either with putty or with a Linux terminal) and execute the following commands:

This will create a so called “bare git” repository. A bare git repository can be used as a central repository to which you push your local repositories.

Ok; now there is a GIT repository created on your Synology. Next create a new Visual Studio solution. Right click the solution name and select “Create Git Repository”. This will add an .git folder to your solution directory and now your solution is in a local Git repository.

Next commit your new solution to the Git repository.Select all files; type your comment and hit “Commit”.

Now push your local repository to the central bare git repository you created earlier. Right click the solution name; choose Git (master) -> Push. The checklist for Git settings will show up if not all settings are valid. For now just click Ok. The Push dialog appears. Specify the remote name; for example: ssh://johndoe@10.0.0.1/volume1/repo1.git

Some useful GIT commands
In Visual Studio goto GIT -> GIT bash; a Bash command prompt will start.
Show available tags:

Create a tag in the GIT bash:

Commit your changes with a message:

Push the tag information:

Delete a tag:

GIT Use Case

Create bare repo on diskstation

On a client clone (initialise) a repository from the dskstation:

[Remote “origin”] can be found in .git/config file; you could add an alias for convenience. A directory repo will be created that contains your files. Add files to your repo directory

Add them to the local stage:

Commit them to the local repo:

Push them to the server repo:

A new branch master will be created. From now on you can use git push (without the origin master)

Share
Synology

Subversion installation on your Synology DiskStation

subversionOn the SynologyWiki is an excellent article about installing Subversion on to your synology diskstation. Is is a step by step guide describing all the details for installing subversion on your diskstation.

Integrate Subversion and Visual Studio

You can also integrate SVN with your visual studio environment (almost like TFS). With the software from ankhSVN, for example, you can perfectly integrate SVN and Visual Studio (2008).

Use the Options window to configure the ankhSVN plugin:
image001
The file “app.config” is checked out; other files are also under version control

image002

View all of your pending changes.
image003

All other regular source control options, like banching and merging, labeling, shelving etcetera are all available.

Share