Easy deployment on azure via powershell

This commit is contained in:
nicolas.dorier 2017-12-14 23:57:58 +09:00
parent 2da1740592
commit b7ec5f68b1
5 changed files with 289 additions and 2 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
*.sh text eol=lf

View File

@ -1,2 +1,41 @@
# btcpayserver-azure
Instructions to deploy BTCPay Server with an Microsoft Azure account
# BTCPayServer Azure
Instructions to deploy BTCPay Server with an Microsoft Azure account.
The following instructions a [Microsoft Azure](https://azure.microsoft.com/) account.
# Deploy with PowerShell
## Step 1: Download and install Azure PowerShell
You can do it by [using PowerShell command line](https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps?view=azurermps-5.0.0) or manually via [Web Platform Installer or MSI](https://docs.microsoft.com/en-us/powershell/azure/other-install?view=azurermps-5.0.0).
## Step 2: Authenticate to Azure
In PowerShell, you first need to authenticate to azure:
```
# This will popup a windows to authenticate to azure
Login-AzureRmAccount
```
If you have multiple subscriptions, select the one you want:
```
# List your subscriptions
Get-AzureRmSubscription
# Select the one you want
Get-AzureRmSubscription SubscriptionId "your subscription" | Select-AzureRmSubscription
```
## Step 3: Run the deployment
Create a new BTCPay Server instance:
```
.\deployOnAzure.ps1 -ResourceGroupName "my-awesome-btcpay"
```
This might take around 5 minutes.
It will print you the DNS name of your server `my-awesome-btcpay.southcentralus.cloudapp.azure.com`, you can browse to it to enjoy your BTCPay instance.

208
azuredeploy.json Normal file
View File

@ -0,0 +1,208 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"type": "string",
"metadata": {
"description": "SSH Username for the Virtual Machine."
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "SSH Password for the Virtual Machine."
}
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_F1",
"metadata": {
"description": "VM size for the Docker host."
}
},
"ubuntuOSVersion": {
"type": "string",
"defaultValue": "14.04.4-LTS",
"metadata": {
"description": "The Ubuntu version for deploying the Docker containers. This will pick a fully patched image of this given Ubuntu version. Allowed values: 14.04.4-LTS, 15.10, 16.04.0-LTS"
},
"allowedValues": [
"14.04.4-LTS",
"15.10",
"16.04.0-LTS"
]
}
},
"variables": {
"imagePublisher": "Canonical",
"imageOffer": "UbuntuServer",
"OSDiskName": "osdiskfordockersimple",
"nicName": "myVMNicD",
"extensionName": "DockerExtension",
"addressPrefix": "10.0.0.0/16",
"subnetName": "Subnet",
"subnetPrefix": "10.0.0.0/24",
"storageAccountType": "Standard_LRS",
"publicIPAddressName": "myPublicIPD",
"publicIPAddressType": "Dynamic",
"vmStorageAccountContainerName": "vhds",
"vmAccountStorageName" : "[uniqueString( resourceGroup().id, deployment().name )]",
"vmName": "MyDockerVM",
"virtualNetworkName": "MyVNETD",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('vmAccountStorageName')]",
"apiVersion": "2016-01-01",
"location": "[resourceGroup().location]",
"kind": "Storage",
"sku": {
"name": "[variables('storageAccountType')]"
}
},
{
"apiVersion": "2017-06-01",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('publicIPAddressName')]",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "[variables('publicIPAddressType')]",
"dnsSettings": {
"domainNameLabel": "[resourceGroup().name]"
}
}
},
{
"apiVersion": "2017-06-01",
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('virtualNetworkName')]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]"
}
}
]
}
},
{
"apiVersion": "2017-06-01",
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('nicName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
},
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
]
}
},
{
"apiVersion": "2017-03-30",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', variables('vmAccountStorageName'))]",
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[variables('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('imagePublisher')]",
"offer": "[variables('imageOffer')]",
"sku": "[parameters('ubuntuOSVersion')]",
"version": "latest"
},
"osDisk": {
"name": "osdisk1",
"vhd": {
"uri": "[concat('http://',variables('vmAccountStorageName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('OSDiskName'),'.vhd')]"
},
"diskSizeGB": 2048,
"caching": "ReadWrite",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
}
]
}
}
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmName'),'/', variables('extensionName'))]",
"apiVersion": "2017-03-30",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "DockerExtension",
"typeHandlerVersion": "1.0",
"autoUpgradeMinorVersion": true,
"settings": { }
}
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmName'),'/', variables('extensionName'))]",
"apiVersion": "2017-03-30",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"settings":
{
"fileUris" : "https://github.com/btcpayserver/btcpayserver-azure/entrypoint.sh",
"commandToExecute" : "./entrypoint.sh"
}
}
}
]
}

34
deployOnAzure.ps1 Normal file
View File

@ -0,0 +1,34 @@
# This
# Assume your ran logged to azure with
# Login-AzureRmAccount
# Then you selected your subscript with
# Get-AzureRmSubscription SubscriptionName "your subscription" | Select-AzureRmSubscription
param([String]$ResourceGroupName)
$rg = $ResourceGroupName
$usr = ([char[]]([char]'a'..[char]'z') + ([char[]]([char]'A'..[char]'Z')) + 0..9 | Sort-Object {Get-Random})[0..8] -join ''
$pass = ([char[]]([char]'a'..[char]'z') + ([char[]]([char]'A'..[char]'Z')) + 0..9 | Sort-Object {Get-Random})[0..16] -join ''
$parameters = `
@{"adminUsername" = $usr;`
"adminPassword" = $pass;}
New-AzureRmResourceGroup -Name $rg -Location "South Central US"
New-AzureRmResourceGroupDeployment -ResourceGroupName $rg -TemplateFile "azuredeploy.json" -TemplateParameterObject $parameters
$site = (Get-AzureRmPublicIpAddress -ResourceGroupName $rg).DnsSettings.Fqdn
$cmd = "ssh $usr@$site"
$temp = "Username: $usr`n"
$temp += "Password: $pass`n"
$temp += "Machine address: $site`n"
$temp += "Command line: $cmd`n"
$temp += "Command line copied to keyboard"
Write-Host $temp
# Copy link of VM to clipboard
$cmd | Set-Clipboard

5
entrypoint.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
sudo apt-get install -y git
git clone https://github.com/btcpayserver/btcpayserver-docker && cd btcpayserver-docker/Regtest
docker-compose up