<commit_before>---
layout: post
title: "Continuous Deployment to Nano Server in Azure."
date: 2016-11-17
---

# Introduction

There are several documented ways online on how to deploy Nano Server to Hyper-V Hosts or to Azure. Additionally, there is documentation on how to deploy a .NET Core Application to a Nano Server.
This article will demonstrate how to deploy a .NET Core Application to a Nano Server in Azure from GitHub using Azure Automation.

## Overview

This article will cover the following:

* Deploying Azure Automation Resources using PowerShell
* Deploying a Nano Server in Azure from GitHub
* Deploying IIS and ASP.NET Core to the Nano Server
* Creating a Runbook to push changes from GitHub to the Nano Server


# Deploy Azure Automation Resources using PowerShell Script

The Azure Resources that are required for this demo will be deployed using the PowerShell script,
**[setup-deployment-env-for-nano-server-in-azure.ps1](https://raw.githubusercontent.com/starkfell/starkfell.github.io/master/scripts/setup-deployment-env-for-nano-server.ps1)**.

This script is responsible for the following:

* Creating two Resource Groups, one for Azure Key Vault and one for an Azure Automation Account
* Creating an Azure Key Vault
* Creating an Azure Automation Account
* Adding the Nano Server Local Administrator Credentials to the Key Vault
* Creating a Self-Signed Certifiate for Nano Server and storing it in the Key Vault

Full details about the Script can be reviewed within the script itself.

Copy the file to your Host and run it using the Syntax and Example below:

Syntax:

```powershell
./setup-deployment-env-for-nano-server-in-azure.ps1 `
-SubscriptionId <SUBSCRIPTION_ID> `
-AzureAutomationResourceGroupName <AZURE_AUTOMATION_RESOURCE_GROUP_NAME> `
-AzureAutomationAccountName <AZURE_AUTOMATION_ACCOUNT_NAME> `
-AzureAutomationPricingTier <AZURE_AUTOMATION_PRICING_TIER> `
-AzureAutomationCertificatePassword <AZURE_AUTOMATION_CERTIFICATE_PASSWORD> `
-KeyVaultResourceGroupName <AZURE_KEY_VAULT_RESOURCE_GROUP_NAME> `
-KeyVaultName <AZURE_KEY_VAULT_NAME> `
-NanoServerLocalAdminUsername <NANO_SERVER_LOCAL_ADMINISTRATOR_USERNAME> `
-NanoServerLocalAdminPassword <NANO_SERVER_LOCAL_ADMINISTRATOR_PASSWORD> `
-NanoServerCertificateName <NANO_SERVER_CERTIFICATE_NAME> `
-NanoServerCertificatePassword <NANO_SERVER_CERTIFICATE_PASSWORD> `
-Location <LOCATIION>

```

Example:

```powershell
./setup-deployment-env-for-nano-server-in-azure.ps1 `
-SubscriptionId <KEY> `
-AzureAutomationResourceGroupName nano-automation `
-AzureAutomationAccountName nano-automation `
-AzureAutomationPricingTier Free `
-AzureAutomationCertificatePassword <PASSWORD>! `
-KeyVaultResourceGroupName nano-key-vault `
-KeyVaultName nanokeyvault `
-NanoServerLocalAdminUsername winadmin `
-NanoServerLocalAdminPassword <PASSWORD>! `
-NanoServerCertificateName nanoservers.lumadeep.com `
-NanoServerCertificatePassword <PASSWORD>! `
-Location westeurope

```

The output from the script should have two entries at the bottom when it completes successfully:

```powershell
Azure Key Vault Resource ID:                           /subscriptions/87d031cb-5fde-412d-b09c-c44c16131488/resourceGroups/nano-key-vault/providers/Microsoft.KeyVault/vaults/nanokeyvault7780.
Nano Server Self-Signed Certificate Secret Identifier: https://nanokeyvault7780.vault.azure.net:443/secrets/nanoservers-lumadeep-com-cert/1f21b4be49dd49a1a05d4eca5400c609.
```


## Deploy a Nano Server in Azure from GitHub

Browse to the **[Deploy Nano Server and VNet into Azure](https://github.com/starkfell/starkfell.github.io/tree/master/arm-templates/deploy-vnet-and-nano-server)** ARM Template 
and clicko on the **Deploy to Azure** button.

If you are not already logged into your Azure Subscription, you will be prompted to do so.

Once you have logged into your Azure Subscription, the Custom deployment blade will appear.

<img src="{{ site.github.url }}/media/continuous-deployment-to-nano-server-in-azure-001.jpg" alt="" />


Under the **BASICS** section, do the following:

* Choose the Azure Subscription you want to deploy to.
* Choose the Name of the Resource Group you want to deploy to or create a new one.
* Choose the Location you want to deploy to.

Under the **SETTINGS** section, the Parmater Values that are recommended that you change are:

* Client ID
* Nano Serveradmin Password

The Parameter Values that you need to provide are:

* Nano Server Key Vault Id<commit_msg>link update.<commit_after>---
layout: post
title: "Continuous Deployment to Nano Server in Azure."
date: 2016-11-17
---

# Introduction

There are several documented ways online on how to deploy Nano Server to Hyper-V Hosts or to Azure. Additionally, there is documentation on how to deploy a .NET Core Application to a Nano Server.
This article will demonstrate how to deploy a .NET Core Application to a Nano Server in Azure from GitHub using Azure Automation.

## Overview

This article will cover the following:

* Deploying Azure Automation Resources using PowerShell
* Deploying a Nano Server in Azure from GitHub
* Deploying IIS and ASP.NET Core to the Nano Server
* Creating a Runbook to push changes from GitHub to the Nano Server


# Deploy Azure Automation Resources using PowerShell Script

The Azure Resources that are required for this demo will be deployed using the PowerShell script,
**[setup-deployment-env-for-nano-server-in-azure.ps1](https://raw.githubusercontent.com/starkfell/starkfell.github.io/master/scripts/setup-deployment-env-for-nano-server.ps1)**.

This script is responsible for the following:

* Creating two Resource Groups, one for Azure Key Vault and one for an Azure Automation Account
* Creating an Azure Key Vault
* Creating an Azure Automation Account
* Adding the Nano Server Local Administrator Credentials to the Key Vault
* Creating a Self-Signed Certifiate for Nano Server and storing it in the Key Vault

Full details about the Script can be reviewed within the script itself.

Copy the file to your Host and run it using the Syntax and Example below:

Syntax:

```powershell
./setup-deployment-env-for-nano-server-in-azure.ps1 `
-SubscriptionId <SUBSCRIPTION_ID> `
-AzureAutomationResourceGroupName <AZURE_AUTOMATION_RESOURCE_GROUP_NAME> `
-AzureAutomationAccountName <AZURE_AUTOMATION_ACCOUNT_NAME> `
-AzureAutomationPricingTier <AZURE_AUTOMATION_PRICING_TIER> `
-AzureAutomationCertificatePassword <<PASSWORD>_AUTOMATION_CERTIFICATE_PASSWORD> `
-KeyVaultResourceGroupName <AZURE_KEY_VAULT_RESOURCE_GROUP_NAME> `
-KeyVaultName <AZURE_KEY_VAULT_NAME> `
-NanoServerLocalAdminUsername <NANO_SERVER_LOCAL_ADMINISTRATOR_USERNAME> `
-NanoServerLocalAdminPassword <<PASSWORD>SERVER_LOCAL_<PASSWORD>> `
-NanoServerCertificateName <NANO_SERVER_CERTIFICATE_NAME> `
-NanoServerCertificatePassword <NANO_SERVER_CERTIFICATE_PASSWORD> `
-Location <LOCATIION>

```

Example:

```powershell
./setup-deployment-env-for-nano-server-in-azure.ps1 `
-SubscriptionId 87d031cb-5fde-412d-b09c-c44c16131488 `
-AzureAutomationResourceGroupName nano-automation `
-AzureAutomationAccountName nano-automation `
-AzureAutomationPricingTier Free `
-AzureAutomationCertificatePassword <PASSWORD>! `
-KeyVaultResourceGroupName nano-key-vault `
-KeyVaultName nanokeyvault `
-NanoServerLocalAdminUsername winadmin `
-NanoServerLocalAdminPassword <PASSWORD>! `
-NanoServerCertificateName nanoservers.lumadeep.com `
-NanoServerCertificatePassword <PASSWORD>! `
-Location westeurope

```

The output from the script should have two entries at the bottom when it completes successfully:

```powershell
Azure Key Vault Resource ID:                           /subscriptions/87d031cb-5fde-412d-b09c-c44c16131488/resourceGroups/nano-key-vault/providers/Microsoft.KeyVault/vaults/nanokeyvault7780.
Nano Server Self-Signed Certificate Secret Identifier: https://nanokeyvault7780.vault.azure.net:443/secrets/nanoservers-lumadeep-com-cert/1f21b4be49dd49a1a05d4eca5400c609.
```


## Deploy a Nano Server in Azure from GitHub

Browse to the **[Deploy Nano Server and VNet into Azure](https://github.com/starkfell/starkfell.github.io/tree/master/arm-templates/deploy-vnet-and-nano-server-in-azure)** ARM Template 
and clicko on the **Deploy to Azure** button.

If you are not already logged into your Azure Subscription, you will be prompted to do so.

Once you have logged into your Azure Subscription, the Custom deployment blade will appear.

<img src="{{ site.github.url }}/media/continuous-deployment-to-nano-server-in-azure-001.jpg" alt="" />


Under the **BASICS** section, do the following:

* Choose the Azure Subscription you want to deploy to.
* Choose the Name of the Resource Group you want to deploy to or create a new one.
* Choose the Location you want to deploy to.

Under the **SETTINGS** section, the Parmater Values that are recommended that you change are:

* Client ID
* Nano Serveradmin Password

The Parameter Values that you need to provide are:

* Nano Server Key Vault Id
{'fraction_non_alphanumeric': 0.07403685092127303, 'fraction_numerical': 0.017085427135678392, 'mean_word_length': 5.284912280701755, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4740407', 'n_tokens_mistral': 2872, 'n_tokens_neox': 2647, 'n_words': 886}