-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Added deployment template that installs DNX + scaffolds console app #1974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
0e869e3
8659cd9
6ef6c80
c1f4d21
ccb49b7
8e65b08
58624b6
ce151a2
a500105
90c4fe8
23a3103
4551fba
bcfe340
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # DNX on Ubuntu 14.04 | ||
|
|
||
| This template will install the cross platform .NET execution context (DNX) on an Ubuntu Server installation, which allows you to write .NET apps on Linux! | ||
|
|
||
| <a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fdnx-on-ubuntu%2Fazuredeploy.json" target="_blank"> | ||
| <img src="http://azuredeploy.net/deploybutton.png"/> | ||
| </a> | ||
| <a href="http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2Azure%2azure-quickstart-templates%2master%2dnx-on-ubuntu%2azuredeploy.json" target="_blank"> | ||
| <img src="http://armviz.io/visualizebutton.png"/> | ||
| </a> | ||
|
|
||
| After deploying the VM - SSH into the machine and do the following to see the DNX app in action: | ||
|
|
||
| ``` | ||
| cd sampleConsoleApp | ||
| dnx run | ||
| ``` | ||
|
|
||
| Open up nano to edit the samplecode `nano ~/sampleConsoleApp/main.cs` code - which has syntax highlighting for C# enabled. | ||
|
|
||
| ``` | ||
| dnu build --framework dnxcore50 | ||
| dnx run | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,221 @@ | ||
| { | ||
| "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | ||
| "contentVersion": "1.0.0.0", | ||
| "parameters": { | ||
| "VMAdminPassword": { | ||
| "defaultValue": "PASSw0rd", | ||
|
||
| "type": "securestring", | ||
| "metadata": { | ||
| "description": "The admin password for the Ubuntu machine" | ||
| } | ||
| }, | ||
| "VMAdminUsername": { | ||
| "defaultValue": "serveradmin", | ||
|
||
| "type": "string", | ||
| "metadata": { | ||
| "description": "The admin username for the Ubuntu machine" | ||
| } | ||
| }, | ||
| "VMName": { | ||
| "defaultValue": "dnx-on-ubuntu", | ||
| "type": "string", | ||
| "metadata": { | ||
| "description": "The VMName" | ||
| } | ||
| } | ||
| }, | ||
| "variables": { | ||
| "NIC name": "dnx-on-ubuntu-nic", | ||
|
||
| "NSG name": "dnx-on-ubuntu-nsg", | ||
| "PIP name": "dnx-on-ubuntu-pip", | ||
| "VNET name": "dnx-on-ubuntu-vnet", | ||
| "SA for diagnostics - name": "[concat(uniquestring(resourceGroup().id), 'diagsa')]", | ||
| "SA for VMs - name": "[concat(uniquestring(resourceGroup().id), 'vmsa')]" | ||
| }, | ||
| "resources": [ | ||
| { | ||
| "type": "Microsoft.Compute/virtualMachines", | ||
| "name": "[parameters('VMName')]", | ||
| "apiVersion": "2015-06-15", | ||
| "location": "westeurope", | ||
|
||
| "properties": { | ||
| "hardwareProfile": { | ||
| "vmSize": "Standard_DS2" | ||
| }, | ||
| "storageProfile": { | ||
| "imageReference": { | ||
| "publisher": "Canonical", | ||
| "offer": "UbuntuServer", | ||
| "sku": "14.04.4-LTS", | ||
| "version": "latest" | ||
| }, | ||
| "osDisk": { | ||
| "name": "[parameters('VMName')]", | ||
| "createOption": "FromImage", | ||
| "vhd": { | ||
| "uri": "[concat('https', '://', variables('SA for VMs - name'), '.blob.core.windows.net', concat('/vhds/', parameters('VMName'),'201641492245.vhd'))]" | ||
| }, | ||
| "caching": "ReadWrite" | ||
| }, | ||
| "dataDisks": [] | ||
| }, | ||
| "osProfile": { | ||
| "computerName": "[parameters('VMName')]", | ||
| "adminUsername": "[parameters('VMAdminUsername')]", | ||
| "linuxConfiguration": { | ||
| "disablePasswordAuthentication": false | ||
| }, | ||
| "secrets": [], | ||
| "adminPassword": "[parameters('VMAdminPassword')]" | ||
| }, | ||
| "networkProfile": { | ||
| "networkInterfaces": [ | ||
| { | ||
| "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('NIC name'))]" | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "dependsOn": [ | ||
| "[resourceId('Microsoft.Storage/storageAccounts', variables('SA for VMs - name'))]", | ||
| "[resourceId('Microsoft.Network/networkInterfaces', variables('NIC name'))]" | ||
| ], | ||
| "resources": [ | ||
| { | ||
| "type": "Microsoft.Compute/virtualMachines/extensions", | ||
| "name": "[concat(parameters('VMName'),'/installcustomscript')]", | ||
| "apiVersion": "2015-06-15", | ||
| "location": "westeurope", | ||
| "dependsOn": [ | ||
| "[concat('Microsoft.Compute/virtualMachines/', parameters('VMName') )]" | ||
| ], | ||
| "properties": { | ||
| "publisher": "Microsoft.OSTCExtensions", | ||
| "type": "CustomScriptForLinux", | ||
| "typeHandlerVersion": "1.4", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have autoupgrademinorversion property |
||
| "settings": { | ||
| "fileUris": [ | ||
| "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/dnx-on-ubuntu/scripts/post_deployment.sh" | ||
| ], | ||
| "commandToExecute": "[concat('/bin/bash post_deployment.sh ', parameters('VMAdminUsername'))]" | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "type": "Microsoft.Network/networkInterfaces", | ||
| "name": "[variables('NIC name')]", | ||
| "apiVersion": "2015-06-15", | ||
| "location": "westeurope", | ||
| "properties": { | ||
| "ipConfigurations": [ | ||
| { | ||
| "name": "ipconfig1", | ||
| "properties": { | ||
| "privateIPAddress": "10.2.0.4", | ||
| "privateIPAllocationMethod": "Dynamic", | ||
| "publicIPAddress": { | ||
| "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('PIP name'))]" | ||
| }, | ||
| "subnet": { | ||
| "id": "[concat(resourceId('Microsoft.Network/virtualNetworks', variables('VNET name')), '/subnets/default')]" | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "dnsSettings": { | ||
| "dnsServers": [] | ||
| }, | ||
| "enableIPForwarding": false, | ||
| "networkSecurityGroup": { | ||
| "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('NSG name'))]" | ||
| } | ||
| }, | ||
| "dependsOn": [ | ||
| "[resourceId('Microsoft.Network/publicIPAddresses', variables('PIP name'))]", | ||
| "[resourceId('Microsoft.Network/virtualNetworks', variables('VNET name'))]", | ||
| "[resourceId('Microsoft.Network/networkSecurityGroups', variables('NSG name'))]" | ||
| ] | ||
| }, | ||
| { | ||
| "type": "Microsoft.Network/networkSecurityGroups", | ||
| "name": "[variables('NSG name')]", | ||
| "apiVersion": "2015-06-15", | ||
| "location": "westeurope", | ||
| "properties": { | ||
| "securityRules": [ | ||
| { | ||
| "name": "default-allow-ssh", | ||
| "properties": { | ||
| "protocol": "Tcp", | ||
| "sourcePortRange": "*", | ||
| "destinationPortRange": "22", | ||
| "sourceAddressPrefix": "*", | ||
| "destinationAddressPrefix": "*", | ||
| "access": "Allow", | ||
| "priority": 1000, | ||
| "direction": "Inbound" | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| "dependsOn": [] | ||
| }, | ||
| { | ||
| "type": "Microsoft.Network/publicIPAddresses", | ||
| "name": "[variables('PIP name')]", | ||
| "apiVersion": "2015-06-15", | ||
| "location": "westeurope", | ||
| "properties": { | ||
| "publicIPAllocationMethod": "Dynamic", | ||
| "idleTimeoutInMinutes": 4 | ||
| }, | ||
| "dependsOn": [] | ||
| }, | ||
| { | ||
| "type": "Microsoft.Network/virtualNetworks", | ||
| "name": "[variables('VNET name')]", | ||
| "apiVersion": "2015-06-15", | ||
| "location": "westeurope", | ||
| "properties": { | ||
| "addressSpace": { | ||
| "addressPrefixes": [ | ||
| "10.2.0.0/16" | ||
| ] | ||
| }, | ||
| "subnets": [ | ||
| { | ||
| "name": "default", | ||
| "properties": { | ||
| "addressPrefix": "10.2.0.0/24" | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| "dependsOn": [] | ||
| }, | ||
| { | ||
| "type": "Microsoft.Storage/storageAccounts", | ||
| "name": "[variables('SA for diagnostics - name')]", | ||
| "apiVersion": "2015-06-15", | ||
| "location": "westeurope", | ||
| "tags": {}, | ||
| "properties": { | ||
| "accountType": "Standard_LRS" | ||
| }, | ||
| "dependsOn": [] | ||
| }, | ||
| { | ||
| "type": "Microsoft.Storage/storageAccounts", | ||
| "name": "[variables('SA for VMs - name')]", | ||
| "apiVersion": "2015-06-15", | ||
| "location": "westeurope", | ||
| "tags": {}, | ||
| "properties": { | ||
| "accountType": "Premium_LRS" | ||
| }, | ||
| "dependsOn": [] | ||
| } | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", | ||
| "contentVersion": "1.0.0.0", | ||
| "parameters": { | ||
| "VMAdminPassword": { | ||
| "value": "PASSw0rd" | ||
| }, | ||
| "VMAdminUsername": { | ||
| "value": "serveradmin" | ||
| }, | ||
| "VMName": { | ||
| "value": "ubuntu-box" | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "itemDisplayName": "DNX on Ubuntu", | ||
| "description": "Spins up an Ubuntu 14.04 server and installs the .NET Execution context (DNX) plus a sample application", | ||
| "summary": ".NET Execution context on Ubuntu server", | ||
| "githubUsername": "jochenvw", | ||
| "dateUpdated": "2016-05-14" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| admin_username=$1 | ||
|
|
||
| # Go to the home dir of the admin user | ||
| cd /home/${admin_username} | ||
|
|
||
| # Download and install DNVM | ||
| echo "Downloading DNVM installation script ..." | ||
| curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh | ||
| dnvm upgrade -r coreclr | ||
|
|
||
| # Set up sample hello world application | ||
| mkdir /home/${admin_username}/sampleConsoleApp | ||
| cat > /home/${admin_username}/sampleConsoleApp/main.cs <<EOL | ||
| namespace DnxApp | ||
| { | ||
| using System; | ||
|
|
||
| public class Program | ||
| { | ||
| public static void Main(string[] args) | ||
| { | ||
| Console.WriteLine("Hello world from DNX !"); | ||
| } | ||
| } | ||
| } | ||
| EOL | ||
|
|
||
| cat > /home/${admin_username}/sampleConsoleApp/project.json <<EOL | ||
| { | ||
| "version": "1.0.0-*", | ||
| "description": "DNX Console application", | ||
| "compilationOptions": { | ||
| "emitEntryPoint": true | ||
| }, | ||
| "dependencies": { | ||
| }, | ||
| "commands": { | ||
| "ConsoleApp1": "ConsoleApp1" | ||
| }, | ||
| "frameworks": { | ||
| "dnx451": { }, | ||
| "dnxcore50": { | ||
| "dependencies": { | ||
| "Microsoft.CSharp": "4.0.1-beta-23516", | ||
| "System.Collections": "4.0.11-beta-23516", | ||
| "System.Console": "4.0.0-beta-23516", | ||
| } | ||
| } | ||
| } | ||
| } | ||
| EOL | ||
|
|
||
| # Restore .NET dependencies and build the application | ||
| cd /home/${admin_username}/sampleConsoleApp | ||
| dnu restore | ||
| dnu build --framework dnxcore50 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #!/bin/bash | ||
| export DEBIAN_FRONTEND=noninteractive | ||
|
|
||
| # This will install ASPNET-Core on an Ubuntu machine | ||
| admin_username=$1 | ||
|
|
||
| # Get package dependencies | ||
| apt-get -y update | ||
| apt-get install -y unzip curl | ||
|
|
||
| # Download the DNX pre-reqs | ||
| apt-get install -y libunwind8 gettext libssl-dev libcurl4-openssl-dev zlib1g libicu-dev uuid-dev | ||
|
|
||
|
|
||
| wget https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/dnx-on-ubuntu/scripts/install-dnx.sh -P /home/${admin_username} | ||
| sudo -u ${admin_username} /bin/bash /home/${admin_username}/install-dnx.sh ${admin_username} | ||
|
|
||
| # Nano syntax highlighting for C# | ||
| cat > /usr/share/nano/csharp.nanorc <<EOL | ||
| syntax "C# source" "\.cs$" | ||
| color green "\<(bool|byte|sbyte|char|decimal|double|float|int|uint|long|ulong|new|object|short|ushort|string|base|this|void)\>" | ||
| color red "\<(as|break|case|catch|checked|continue|default|do|else|finally|fixed|for|foreach|goto|if|is|lock|return|switch|throw|try|unchecked|while)\>" | ||
| color cyan "\<(abstract|class|const|delegate|enum|event|explicit|extern|implicit|in|internal|interface|namespace|operator|out|override|params|private|protected|public|readonly|ref|sealed|sizeof|static|struct|typeof|using|virtual|volatile)\>" | ||
| color red ""[^\"]*"" | ||
| color yellow "\<(true|false|null)\>" | ||
| color blue "//.*" | ||
| color blue start="/\*" end="\*/" | ||
| color brightblue start="/\*\*" end="\*/" | ||
| color brightgreen,green " +$" | ||
| EOL | ||
|
|
||
| sudo echo "include \"/usr/share/nano/csharp.nanorc\"" > /etc/nanorc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this and others below should be vmAdminPassword :)