Azure / azure-quickstart-templates

Azure Quickstart Templates
https://aka.ms/azqst
MIT License
14.06k stars 16.13k forks source link

"Failed to download all specified files" error in customScript extension for Service Fabric Cluster #4010

Closed gustavo-vargas-leon closed 6 years ago

gustavo-vargas-leon commented 7 years ago

service-fabric-secure-cluster-5-node-1-nodetype https://github.com/Azure/azure-quickstart-templates/tree/master/service-fabric-secure-cluster-5-node-1-nodetype

I need to deploy an Azure Service Fabric cluster and execute a custom script in the VM Scale set, so I added the "customScript" extension to the Microsoft.Compute/virtualMachineScaleSets section of the template. But when I try to deploy it I always get this error:

New-AzureRmResourceGroupDeployment : 8:04:07 PM - VM has reported a failure when processing 
extension 'customScript'. Error message: "Failed to download all specified files. Exiting. Error Message: 
The remote server returned an error: (404) Not Found.".
At line:1 char:1
+ New-AzureRmResourceGroupDeployment -ResourceGroupName "internal-rnd"  ...
+ 
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
    + FullyQualifiedErrorId : 
Microsoft.Azure.Commands.Resources.NewAzureResourceGroupDeploymentCommand

This is the section on the template

          {
            "name": "customScript",
            "properties": {
              "publisher": "Microsoft.Compute",
              "settings": {
                "fileUris": [
                  "[concat(parameters('_artifactsLocation'), '/scripts/MyScript.ps1')]"
                ]
              },
              "typeHandlerVersion": "1.8",
              "autoUpgradeMinorVersion": true,
              "protectedSettings": {
                "commandToExecute": "powershell -ExecutionPolicy Unrestricted -File MyScript.ps1"
              },
              "type": "CustomScriptExtension"
            }
          }

This is the folder where the template is, and inside the scripts folder is the MyScript.ps1 file.

image

This is the Powershell command I'm using to deploy:

New-AzureRmResourceGroupDeployment -ResourceGroupName "internal-rnd" -TemplateFile .\azuredeploy.json -TemplateParameterFile .\azuredeploy.parameters.json

And for I what I've read there no need to previously upload the scripts to an Azure Storage.

I've spent lots of hours trying different things and now I'm stuck. Am I doing something wrong?

Thanks in advance.

jfuller28495 commented 6 years ago

I am also experiencing the same issue. I know these templates have worked before, however when I attempted to deploy them into a new Azure tenant (accounting for the change in environmental variables) I reached this same error message.

patild05 commented 6 years ago

I face the same error when I use the file from existing storage account or even from Git. Any comments?

gustavo-vargas-leon commented 6 years ago

@jfuller28495, @patild05 : What worked for me at the end was to upload the script file into an Azure Storage blob and to use a sasKey like this:

             {
                "name": "customScript",
                "properties": {
                  "publisher": "Microsoft.Compute",
                  "settings": {
                    "fileUris": [
                      "[concat(parameters('_artifactsLocation'), parameters('scriptFileName'))]"
                    ]
                  },
                  "typeHandlerVersion": "1.8",
                  "autoUpgradeMinorVersion": true,
                  "protectedSettings": {
                    "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File MyScript.ps1",  
                    "storageAccountName": "[parameters('storageAccounts_customscriptteststorage_name')]",
                    "storageAccountKey": "[parameters('sasKey')]"

                  },
                  "type": "CustomScriptExtension"
                }
              }
subash544772 commented 6 years ago

@mdverde it does not work for me .i tried same thing what you have suggested .

dopic commented 6 years ago

Hi, I have the same problem.

I generate the SAS token using the cmdlet "New-AzureStorageBlobSASToken", and when I try to update my scale set with it, it fails. Generally it works once or two times, but after that, it starts to raise the error: "The remote server returned an error: (403) Forbidden". (PS.: Every time that I try to execute the update, I use a brand new SAS token, its not the same).

If I take the same SAS token and try it on browser, it starts the download normally.

majorvin commented 5 years ago

@dopic did you get it to work for you?

Deepudev13 commented 5 years ago

I am also facing same issue! Is there any resolution for this issue or closed without resolution!

dogejim commented 5 years ago

Fixed this on my end by going to blob container --> Overview --> Change access level --> Container (anonymous read access for containers and blobs)

wenbya commented 4 years ago

Fixed this on my end by going to blob container --> Overview --> Change access level --> Container (anonymous read access for containers and blobs)

doing this will show others your script. it's not a recommended way. the storage account name and key here are design to avoid this.

halradaideh commented 4 years ago

any update here ? /reopen

dnyaneshwar-surywanshi commented 3 years ago

I resolved the issue just append the SAS token with fileUris.

agyss commented 5 months ago

Solution is to use protectedsettings instead of settings. Only fileUris and commandToExecute are supported in the settings section...

The error message one receives is very bad IMHO and the documentation could be better, but it actually contains it as of today (28.05.2024):

You can set the following values in either public or protected settings. The extension rejects any configuration where these values are set in both public and protected settings.

 - commandToExecute
 - fileUris