0

I am new to Azure/.Net/C# world and I am trying to learn how to deploy an ASP.Net webapp to Azure. I started with this tutorial. Created a VM, Created a webapp and published it. However, the webapp fails to launch.

I connected to the VM via remote desktop. IIS Logs seem to indicate that I am running into this problem.

However, the VM is extremely restricted and locked down. There is no way to download anything. Even though I am the administrator, I can't open anything on this machine except internet explorer.

I tried creating a normal VM but I can't publish to this VM from Visual Studio. Apparently the VM must be created using the 'Create Azure VM' button mentioned in the first link which sets up the VM in a particular way.

Community
  • 1
  • 1
Prashant Saraswat
  • 838
  • 1
  • 8
  • 20
  • why you don't use App Services? – Alexan Jun 12 '19 at 22:31
  • Thanks for that comment. I am very new to this and just following tutorials provided by microsoft. Also, my eventual interest is in deploying a microsoft bot sample which is deployed similarly ( via a visual studio app to azure). – Prashant Saraswat Jun 12 '19 at 22:43
  • it's easy and cheaper to use App Services, see https://tutorials.visualstudio.com/aspnet-azure/intro You only need to create VM if you really need this. Maybe it make sense for learning. – Alexan Jun 12 '19 at 23:02
  • I understand but my eventual goal is to deploy this: https://github.com/microsoftgraph/microsoft-graph-comms-samples/tree/master/Samples/V1.0Samples/LocalMediaSamples/AudioVideoPlaybackBot This one doesn't use app services – Prashant Saraswat Jun 12 '19 at 23:04
  • I don't have much experience in VM in Azure, but I think it's some settings, maybe firewall – Alexan Jun 12 '19 at 23:09

1 Answers1

0

@Prashant,

By Clicking on Create Azure VM , it ensures to install the all dependency by using Azure Marketplace ARM template which you can find it here.

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "virtualMachineName": {
            "type": "string"
        },
        "adminUsername": {
            "type": "string"
        },
        "adminPassword": {
            "type": "securestring"
        }
    },
    "variables": {
        "safeVmName": "[toLower(replace(parameters('virtualMachineName'), '-', ''))]",
        "virtualMachineSize": "Standard_DS1_v2",
        "virtualNetworkName": "[concat(variables('safeVmName'), '-vnet')]",
        "networkInterfaceName": "[concat(variables('safeVmName'), '-neti')]",
        "networkSecurityGroupName": "[concat(parameters('virtualMachineName'), '-nsg')]",
        "diagnosticsStorageAccountName": "[concat(variables('safeVmName'), 'diag')]",
        "diagnosticsStorageAccountType": "Standard_LRS",
        "diagnosticsStorageAccountId": "[concat('Microsoft.Storage/storageAccounts/', variables('diagnosticsStorageAccountName'))]",
        "addressPrefix": "10.0.5.0/24",
        "subnetName": "default",
        "subnetPrefix": "10.0.5.0/24",
        "publicIpAddressName": "[concat(parameters('virtualMachineName'), '-ip')]",
        "publicIpAddressType": "Dynamic",
        "publicIpAddressSku": "Basic",
        "dnsNamePrefix": "[toLower(concat(parameters('virtualMachineName'), '-', take(guid(resourceGroup().id), 8)))]",
        "autoShutdownStatus": "Enabled",
        "autoShutdownTime": "19:00",
        "autoShutdownTimeZone": "UTC",
        "autoShutdownNotificationStatus": "Disabled",
        "vnetId": "[resourceId(resourceGroup().name,'Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
        "subnetRef": "[concat(variables('vnetId'), '/subnets/', variables('subnetName'))]"
    },
    "resources": [
        {
            "name": "[parameters('virtualMachineName')]",
            "type": "Microsoft.Compute/virtualMachines",
            "apiVersion": "2016-04-30-preview",
            "location": "[resourceGroup().location]",
            "dependsOn": [
                "[concat('Microsoft.Network/networkInterfaces/', variables('networkInterfaceName'))]",
                "[concat('Microsoft.Storage/storageAccounts/', variables('diagnosticsStorageAccountName'))]"
            ],
            "properties": {
                "osProfile": {
                    "computerName": "[parameters('virtualMachineName')]",
                    "adminUsername": "[parameters('adminUsername')]",
                    "adminPassword": "[parameters('adminPassword')]",
                    "windowsConfiguration": {
                        "provisionVmAgent": "true"
                    }
                },
                "hardwareProfile": {
                    "vmSize": "[variables('virtualMachineSize')]"
                },
                "storageProfile": {
                    "imageReference": {
                        "publisher": "MicrosoftWindowsServer",
                        "offer": "WindowsServer",
                        "sku": "2016-Datacenter",
                        "version": "latest"
                    },
                    "osDisk": {
                        "createOption": "fromImage",
                        "managedDisk": {
                            "storageAccountType": "Premium_LRS"
                        }
                    },
                    "dataDisks": []
                },
                "networkProfile": {
                    "networkInterfaces": [
                        {
                            "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('networkInterfaceName'))]"
                        }
                    ]
                },
                "diagnosticsProfile": {
                    "bootDiagnostics": {
                        "enabled": true,
                        "storageUri": "[reference(resourceId(resourceGroup().name, 'Microsoft.Storage/storageAccounts', variables('diagnosticsStorageAccountName')), '2015-06-15').primaryEndpoints['blob']]"
                    }
                }
            },
            "resources": [
                {
                    "type": "extensions",
                    "name": "CustomScriptExtension",
                    "apiVersion": "2015-06-15",
                    "location": "[resourceGroup().location]",
                    "dependsOn": [
                        "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
                    ],
                    "properties": {
                        "publisher": "Microsoft.Compute",
                        "type": "CustomScriptExtension",
                        "typeHandlerVersion": "1.8",
                        "autoUpgradeMinorVersion": true,
                        "settings": {
                            "fileUris": [
                                "https://raw.githubusercontent.com/justcla/ASPNet-VM/master/setup.ps1"
                            ],
                            "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File setup.ps1"
                        }
                    }
                }
            ]
        },
        {
            "name": "[concat('shutdown-computevm-', parameters('virtualMachineName'))]",
            "type": "Microsoft.DevTestLab/schedules",
            "apiVersion": "2017-04-26-preview",
            "location": "[resourceGroup().location]",
            "properties": {
                "status": "[variables('autoShutdownStatus')]",
                "taskType": "ComputeVmShutdownTask",
                "dailyRecurrence": {
                    "time": "[variables('autoShutdownTime')]"
                },
                "timeZoneId": "[variables('autoShutdownTimeZone')]",
                "targetResourceId": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]",
                "notificationSettings": {
                    "status": "[variables('autoShutdownNotificationStatus')]",
                    "timeInMinutes": "30"
                }
            },
            "dependsOn": [
                "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
            ]
        },
        {
            "name": "[variables('diagnosticsStorageAccountName')]",
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2015-06-15",
            "location": "[resourceGroup().location]",
            "properties": {
                "accountType": "[variables('diagnosticsStorageAccountType')]"
            }
        },
        {
            "name": "[variables('virtualNetworkName')]",
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2016-12-01",
            "location": "[resourceGroup().location]",
            "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "[variables('addressPrefix')]"
                    ]
                },
                "subnets": [
                    {
                        "name": "[variables('subnetName')]",
                        "properties": {
                            "addressPrefix": "[variables('subnetPrefix')]"
                        }
                    }
                ]
            }
        },
        {
            "name": "[variables('networkInterfaceName')]",
            "type": "Microsoft.Network/networkInterfaces",
            "apiVersion": "2016-09-01",
            "location": "[resourceGroup().location]",
            "dependsOn": [
                "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]",
                "[concat('Microsoft.Network/publicIpAddresses/', variables('publicIpAddressName'))]",
                "[concat('Microsoft.Network/networkSecurityGroups/', variables('networkSecurityGroupName'))]"
            ],
            "properties": {
                "ipConfigurations": [
                    {
                        "name": "ipconfig1",
                        "properties": {
                            "subnet": {
                                "id": "[variables('subnetRef')]"
                            },
                            "privateIPAllocationMethod": "Dynamic",
                            "publicIpAddress": {
                                "id": "[resourceId(resourceGroup().name,'Microsoft.Network/publicIpAddresses', variables('publicIpAddressName'))]"
                            }
                        }
                    }
                ],
                "networkSecurityGroup": {
                    "id": "[resourceId(resourceGroup().name, 'Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
                }
            }
        },
        {
            "name": "[variables('publicIpAddressName')]",
            "type": "Microsoft.Network/publicIpAddresses",
            "apiVersion": "2017-08-01",
            "location": "[resourceGroup().location]",
            "properties": {
                "publicIpAllocationMethod": "[variables('publicIpAddressType')]",
                "dnsSettings": {
                    "domainNameLabel": "[variables('dnsNamePrefix')]",
                    "fqdn": "[concat(variables('dnsNamePrefix'), resourceGroup().location, '.cloudapp.azure.com')]"
                }
            },
            "sku": {
                "name": "[variables('publicIpAddressSku')]"
            }
        },
        {
            "name": "[variables('networkSecurityGroupName')]",
            "type": "Microsoft.Network/networkSecurityGroups",
            "apiVersion": "2017-06-01",
            "location": "[resourceGroup().location]",
            "properties": {
                "securityRules": [
                    {
                        "name": "default-allow-rdp",
                        "properties": {
                            "priority": 1000,
                            "protocol": "TCP",
                            "access": "Allow",
                            "direction": "Inbound",
                            "sourceAddressPrefix": "*",
                            "sourcePortRange": "*",
                            "destinationAddressPrefix": "*",
                            "destinationPortRange": "3389"
                        }
                    },
                    {
                        "name": "http",
                        "properties": {
                            "priority": 100,
                            "protocol": "*",
                            "access": "Allow",
                            "direction": "Inbound",
                            "sourceAddressPrefix": "*",
                            "sourcePortRange": "*",
                            "destinationAddressPrefix": "*",
                            "destinationPortRange": "80"
                        }
                    },
                    {
                        "name": "WebDeploy",
                        "properties": {
                            "priority": 1010,
                            "protocol": "*",
                            "access": "Allow",
                            "direction": "Inbound",
                            "sourceAddressPrefix": "*",
                            "sourcePortRange": "*",
                            "destinationAddressPrefix": "*",
                            "destinationPortRange": "8172"
                        }
                    }
                ]
            }
        }
    ],
    "outputs": {
        "adminUsername": {
            "type": "string",
            "value": "[parameters('adminUsername')]"
        }
    }
}

Internally it creates the VM , setting up the right policy , create the network security group , opening the port for communication and right executable by calling below powershell script:

https://raw.githubusercontent.com/justcla/ASPNet-VM/master/setup.ps1

It ensures that for Dot net project you will have all the dependencies installed in VM .

I tried using the same template and deployed my ASP.Net MVC web project and it worked.

I would suggest you to use the same template for VM creationg or install all required capabilities in your VM before deploying the solution.

Please do try and reach out to me for any issues.Hope it helps.

Mohit Verma
  • 5,140
  • 2
  • 12
  • 27
  • I tried again today but I run into a different problem when trying to publish. Visual studio says - Could not reach the Web Deploy endpoint on the specified virtual machine. I am able to connect to the machine via remote desktop – Prashant Saraswat Jun 13 '19 at 17:00
  • It looks like this is a windows 7 issue. When I switched to windows 10 a lot of such problems disappeared. – Prashant Saraswat Jun 18 '19 at 15:17
  • Glad to know it sorted out for you. – Mohit Verma Jun 18 '19 at 16:33
  • If anyone else comes across "Could not reach the Web Deploy endpoint" error, try installing Management Service and enable it for remote connections via port 8172. https://port135.com/2019/07/29/could-not-reach-the-web-deploy-endpoint-specified-virtual-machine/ – Ned Jul 29 '19 at 20:20