diff --git a/dnx-on-ubuntu/README.md b/dnx-on-ubuntu/README.md new file mode 100644 index 000000000000..3a962ec806ba --- /dev/null +++ b/dnx-on-ubuntu/README.md @@ -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! + + + + + + + + +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 +``` \ No newline at end of file diff --git a/dnx-on-ubuntu/azuredeploy.json b/dnx-on-ubuntu/azuredeploy.json new file mode 100644 index 000000000000..0dfd69facfd3 --- /dev/null +++ b/dnx-on-ubuntu/azuredeploy.json @@ -0,0 +1,221 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "vmAdminPassword": { + "type": "securestring", + "metadata": { + "description": "The admin password for the Ubuntu machine" + } + }, + "vmAdminUsername": { + "type": "string", + "metadata": { + "description": "The admin username for the Ubuntu machine" + } + }, + "vmName": { + "defaultValue": "dnx-on-ubuntu", + "type": "string", + "metadata": { + "description": "The name of the Ubuntu machine" + } + } + }, + "variables": { + "prefix": "dnx-on-ubuntu", + "nicName": "[concat(variables('prefix'),'-nic')]", + "nsgName": "[concat(variables('prefix'),'-nsg')]", + "pipName": "[concat(variables('prefix'),'-pip')]", + "vnetName": "[concat(variables('prefix'),'-vnet')]", + "storageAccountDiagnostics": "[concat(uniquestring(resourceGroup().id), 'diagsa')]", + "storageAccountVms": "[concat(uniquestring(resourceGroup().id), 'vmsa')]" + }, + "resources": [ + { + "type": "Microsoft.Compute/virtualMachines", + "name": "[parameters('vmName')]", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "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('storageAccountVms'), '.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('nicName'))]" + } + ] + } + }, + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountVms'))]", + "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" + ], + "resources": [ + { + "type": "Microsoft.Compute/virtualMachines/extensions", + "name": "[concat(parameters('vmName'),'/installcustomscript')]", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "dependsOn": [ + "[concat('Microsoft.Compute/virtualMachines/', parameters('vmName') )]" + ], + "properties": { + "publisher": "Microsoft.OSTCExtensions", + "type": "CustomScriptForLinux", + "typeHandlerVersion": "1.4", + "autoUpgradeMinorVersion": true, + "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('nicName')]", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "properties": { + "ipConfigurations": [ + { + "name": "ipconfig1", + "properties": { + "privateIPAddress": "10.2.0.4", + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('pipName'))]" + }, + "subnet": { + "id": "[concat(resourceId('Microsoft.Network/virtualNetworks', variables('vnetName')), '/subnets/default')]" + } + } + } + ], + "dnsSettings": { + "dnsServers": [] + }, + "enableIPForwarding": false, + "networkSecurityGroup": { + "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]" + } + }, + "dependsOn": [ + "[resourceId('Microsoft.Network/publicIPAddresses', variables('pipName'))]", + "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]", + "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]" + ] + }, + { + "type": "Microsoft.Network/networkSecurityGroups", + "name": "[variables('nsgName')]", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "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('pipName')]", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "properties": { + "publicIPAllocationMethod": "Dynamic", + "idleTimeoutInMinutes": 4 + }, + "dependsOn": [] + }, + { + "type": "Microsoft.Network/virtualNetworks", + "name": "[variables('vnetName')]", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "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('storageAccountDiagnostics')]", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "tags": {}, + "properties": { + "accountType": "Standard_LRS" + }, + "dependsOn": [] + }, + { + "type": "Microsoft.Storage/storageAccounts", + "name": "[variables('storageAccountVms')]", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "tags": {}, + "properties": { + "accountType": "Premium_LRS" + }, + "dependsOn": [] + } + ] +} \ No newline at end of file diff --git a/dnx-on-ubuntu/azuredeploy.parameters.json b/dnx-on-ubuntu/azuredeploy.parameters.json new file mode 100644 index 000000000000..467ab9038089 --- /dev/null +++ b/dnx-on-ubuntu/azuredeploy.parameters.json @@ -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" + } + } +} \ No newline at end of file diff --git a/dnx-on-ubuntu/metadata.json b/dnx-on-ubuntu/metadata.json new file mode 100644 index 000000000000..b1b0434364aa --- /dev/null +++ b/dnx-on-ubuntu/metadata.json @@ -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" +} \ No newline at end of file diff --git a/dnx-on-ubuntu/scripts/install-dnx.sh b/dnx-on-ubuntu/scripts/install-dnx.sh new file mode 100644 index 000000000000..5de7ecf79a28 --- /dev/null +++ b/dnx-on-ubuntu/scripts/install-dnx.sh @@ -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 < /home/${admin_username}/sampleConsoleApp/project.json < /usr/share/nano/csharp.nanorc <" +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 \ No newline at end of file