Share via


Azure VM - Custom Script Extension Issue - Remote name could not be resolved

Question

Tuesday, March 5, 2019 5:25 PM

I have an issue where I can't get a custom script going on a Windows VM. It will always give me the same issue/error regardless of access. I've tried with ARM Template, Powershell and through portal with all same results.

 

Error I receive:

Failed to download all specified files. Exiting. Error Message: The remote name could not be resolved: 'storageaccount.blob.core.windows.net

 

Now I don't understand this as I run a custom script extension on a linux VM and it works just fine referencing the exact same storage account and container. I also run the command I use to execute on it's own on the server as a test and it works if it's in the directory I have the script, so it should work.

 

Asking to see if anyone has had the same issue or not or any suggestions if I am maybe missing something simple? I'm at a standstill on what to try next at this point and have compared mine to others on github and looks like it should work. I also reference this and looks OK as well /en-us/azure/virtual-machines/extensions/custom-script-windows

 

ARM Template Code used

 

 {

      "apiVersion": "2018-06-01",

      "type": "Microsoft.Compute/virtualMachines/extensions",

      "name": "[concat(parameters('dnsLabelPrefix'),'/CustomScriptExtension')]",

      "location": "[resourceGroup().location]",

      "dependsOn": [

        "[resourceId('Microsoft.Compute/virtualMachines', parameters('dnsLabelPrefix'))]"

      ],

      "properties": {

        "publisher": "Microsoft.Compute",

        "type": "CustomScriptExtension",

        "typeHandlerVersion": "1.9",

        "autoUpgradeMinorVersion": true,

        "settings": {

          "fileUris": [

            "https://storageaccount.blob.core.windows.net/artifacts/CreateUser.ps1"

          ],

          "timestamp": 123456789

        },

        "protectedSettings": {

          "commandToExecute": "powershell -ExecutionPolicy Unrestricted -File CreateUser.ps1",

          "storageAccountName": "storageaccount",

          "storageAccountKey": "storagekey"

        }

      }

    }

 

Powershell Command used

 

$fileUri = @("https://storageaccount.blob.core.windows.net/artifacts/CreateUser.ps1")

 

$Settings = @{"fileUris" = $fileUri};

 

$storageaccname = "storageaccount"

$storagekey = "storagekey"

$ProtectedSettings = @{"storageAccountName" = $storageaccname; "storageAccountKey" = $storagekey; "commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File CreateUser.ps1"};

 

 

 Set-AzureRmVMCustomScriptExtension -ResourceGroupName "resource group" -Location "Canada Central" `

 -VMName "vmname" -Name "CustomScript" -TypeHandlerVersion "1.1" -StorageAccountName "storageaccount" `

 -StorageAccountKey "storagekey" -FileName "CreateUser.ps1" -ContainerName "artifacts"

 

If anyone has any ideas any help is always appreciated

All replies (7)

Tuesday, March 5, 2019 8:07 PM

Can you login to the VM and check to see if we have any more details on why it is failing? 

/en-us/azure/virtual-machines/extensions/custom-script-windows#troubleshoot-and-support

Logs are located inside the VM at 

C:\WindowsAzure\Logs\Plugins\Microsoft.Compute.CustomScriptExtension


Wednesday, March 6, 2019 8:18 AM

Hi Luke,

It seems there is something needs to fixed in this custom extension code for windows. I had similar issue so I am giving you below template that can be used to create windows VM with custom extension.

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {},
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Storage/storageAccounts",
            "name": "[toLower('Goudevboxstorage')]",
            "apiVersion": "2015-06-15",
            "location": "[resourceGroup().location]",
            "tags": {
                "displayName": "Goudevbox Storage Account"
            },
            "properties": {
                "accountType": "Standard_LRS"
            }
        },
        {
            "apiVersion": "2015-06-15",
            "type": "Microsoft.Network/publicIPAddresses",
            "name": "Goudevbox-PublicIP",
            "location": "[resourceGroup().location]",
            "tags": {
                "displayName": "PublicIPAddress"
            },
            "properties": {
                "publicIPAllocationMethod": "Dynamic",
                "dnsSettings": {
                    "domainNameLabel": "[toLower('Goudevbox')]"
                }
            }
        },
        {
            "apiVersion": "2015-06-15",
            "type": "Microsoft.Network/virtualNetworks",
            "name": "Goudevbox-VirtualNetwork",
            "location": "[resourceGroup().location]",
            "tags": {
                "displayName": "VirtualNetwork"
            },
            "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "10.0.0.0/16"
                    ]
                },
                "subnets": [
                    {
                        "name": "Goudevbox-VirtualNetwork-Subnet",
                        "properties": {
                            "addressPrefix": "10.0.0.0/24"
                        }
                    }
                ]
            }
        },
        {
            "apiVersion": "2015-06-15",
            "type": "Microsoft.Network/networkInterfaces",
            "name": "Goudevbox-NetworkInterface",
            "location": "[resourceGroup().location]",
            "dependsOn": [
                "Microsoft.Network/publicIPAddresses/Goudevbox-PublicIP",
                "Microsoft.Network/virtualNetworks/Goudevbox-VirtualNetwork"
            ],
            "tags": {
                "displayName": "Goudevbox Network Interface"
            },
            "properties": {
                "ipConfigurations": [
                    {
                        "name": "ipconfig1",
                        "properties": {
                            "privateIPAllocationMethod": "Dynamic",
                            "publicIPAddress": {
                                "id": "[resourceId('Microsoft.Network/publicIPAddresses', 'Goudevbox-PublicIP')]"
                            },
                            "subnet": {
                                "id": "[concat(resourceId('Microsoft.Network/virtualNetworks', 'Goudevbox-VirtualNetwork'), '/subnets/Goudevbox-VirtualNetwork-Subnet')]"
                            }
                        }
                    }
                ]
            }
        },
        {
            "apiVersion": "2017-03-30",
            "type": "Microsoft.Compute/virtualMachines",
            "name": "Goudevbox",
            "location": "[resourceGroup().location]",
            "dependsOn": [
                "[concat('Microsoft.Storage/storageAccounts/', toLower('Goudevboxstorage'))]",
                "Microsoft.Network/networkInterfaces/Goudevbox-NetworkInterface"
            ],
            "tags": {
                "displayName": "Goudevbox"
            },
            "properties": {
                "hardwareProfile": {
                    "vmSize": "Standard_A2"
                },
                "osProfile": {
                    "computerName": "Goudevbox",
                    "adminUsername": "Gourav",
                    "adminPassword": "Test@1234567890"
                },
                "storageProfile": {
                    "imageReference": {
                        "publisher": "MicrosoftWindowsServer",
                        "offer": "WindowsServer",
                        "sku": "2012-R2-Datacenter",
                        "version": "latest"
                    },
                    "osDisk": {
                        "name": "GoudevboxOSDisk",
                        "caching": "ReadWrite",
                        "createOption": "FromImage"
                    }
                },
                "networkProfile": {
                    "networkInterfaces": [
                        {
                            "id": "[resourceId('Microsoft.Network/networkInterfaces', 'Goudevbox-NetworkInterface')]"
                        }
                    ]
                },
                "diagnosticsProfile": {
                    "bootDiagnostics": {
                        "enabled": true,
                        "storageUri": "[concat('http://', toLower('Goudevboxstorage'), '.blob.core.windows.net')]"
                    }
                }
            },
            "resources": [
                {
                    "apiVersion": "2015-06-15",
                    "type": "extensions",
                    "name": "config-app",
                    "location": "[resourceGroup().location]",
                    "dependsOn": [
                        "[concat('Microsoft.Compute/virtualMachines/', 'Goudevbox')]"
                    ],
                    "tags": {
                        "displayName": "config-app"
                    },
                    "properties": {
                        "publisher": "Microsoft.Compute",
                        "type": "CustomScriptExtension",
                        "typeHandlerVersion": "1.9",
                        "autoUpgradeMinorVersion": true,
                        "settings": {
                            "fileUris": [
                                "https://raw.githubusercontent.com/unpredictablegourav/AzureVMTest/master/Extesnsion.ps1"
                            ]
                        },
                        "protectedSettings": {
                            "commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -File ', './Extesnsion.ps1')]"
                        }
                    }
                }
            ]
        }
     
    ],
    "outputs": {}
}

Using this script you can create windows VM with custom extension just replace your powershell URI.

Using this I am creating 2012 OS server, you could change below given parameters in template as per your requirement. 

"publisher": "MicrosoftWindowsServer",
                        "offer": "WindowsServer",
                        "sku": "2012-R2-Datacenter",
                        "version": "latest"

Hope this helps :)

 

Cheers, Gourav Please remember to mark the replies as answers if it helped.


Wednesday, March 6, 2019 3:37 PM

I did end up getting it to work if I created a new VM and Storage account.... something I haven't figured out yet is what was wrong with the original setup I had. Although, strange it worked for my linux VMs .sh scripts using the extension but not windows. 


Wednesday, March 6, 2019 4:34 PM

I did end up getting it to work if I created a new VM and Storage account.... something I haven't figured out yet is what was wrong with the original setup I had. Although, strange it worked for my linux VMs .sh scripts using the extension but not windows. 

Indeed, we need to find out the culprit. However i have just given you a workaround for windows VM with custom extension.

Cheers, Gourav Please remember to mark the replies as answers if it helped.


Wednesday, March 6, 2019 8:20 PM

And thank you for that by the way, it's much appreciated!


Friday, March 8, 2019 10:06 AM

And thank you for that by the way, it's much appreciated!

No need of thanks :)

You could check this thread for further information. This might help you

Cheers, Gourav Please remember to mark the replies as answers if it helped.


Friday, March 22, 2019 8:03 PM

Any update on this issue? If the answer helped you resolve the problem remember to mark as answer so others in the community can easily find the solution