The following forum(s) have migrated to Microsoft Q&A (Preview): Azure Virtual Machines!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
Custom script extension set on virtual machine scale set(vmss) of linux is not working on existing instances in it. RRS feed

  • Question

  • I have set extension on vmss using az command az vmss extension set --publisher Microsoft.Azure.Extensions --version 2.0 --name CustomScript --resource-group resource_group_name --vmss-name vmss_name --settings @./customConfig.json

    customConfig.json 

    {
      "fileUris": ["publiclinkoffile"],
      "commandToExecute": "./filename"
    }


    Extension is set successfully but it is reflecting only on the newly scaled instances.
    Attached /var/log/azure/custom-script/handler.log of the existing instance where extension is not working.

    + /var/lib/waagent/Microsoft.Azure.Extensions.CustomScript-2.1.2/bin/custom-script-extension install
    time=2019-11-11T07:02:55Z version=v2.1.2/git@b73cc91-clean operation=install seq=1 event=start
    time=2019-11-11T07:02:55Z version=v2.1.2/git@b73cc91-clean operation=install seq=1 status="not reported for operation (by design)"
    time=2019-11-11T07:02:55Z version=v2.1.2/git@b73cc91-clean operation=install seq=1 event="migrate to mrseq" error="Can't find out seqnum from /var/lib/waagent/Microsoft.Azure.Extensions.CustomScript-2.1.2/status, not enough files."
    time=2019-11-11T07:02:55Z version=v2.1.2/git@b73cc91-clean operation=install seq=1 event="created data dir" path=/var/lib/waagent/custom-script
    time=2019-11-11T07:02:55Z version=v2.1.2/git@b73cc91-clean operation=install seq=1 event=installed
    time=2019-11-11T07:02:55Z version=v2.1.2/git@b73cc91-clean operation=install seq=1 status="not reported for operation (by design)"
    time=2019-11-11T07:02:55Z version=v2.1.2/git@b73cc91-clean operation=install seq=1 event=end
    Writing a placeholder status file indicating progress before forking: /var/lib/waagent/Microsoft.Azure.Extensions.CustomScript-2.1.2/status/1.status
    + nohup /var/lib/waagent/Microsoft.Azure.Extensions.CustomScript-2.1.2/bin/custom-script-extension enable
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event=start
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event=pre-check
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="comparing seqnum" path=mrseq
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="seqnum saved" path=mrseq
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="reading configuration"
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="read configuration"
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="validating json schema"
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="json schema valid"
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="parsing configuration json"
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="parsed configuration json"
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="validating configuration logically"
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="validated configuration"
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="creating output directory" path=/var/lib/waagent/custom-script/download/1
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="created output directory"
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 files=0
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="executing command" output=/var/lib/waagent/custom-script/download/1
    time=2019-11-11T07:02:58Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="executing protected commandToExecute" output=/var/lib/waagent/custom-script/download/1

    time=2019-11-11T07:03:42Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="executed command" output=/var/lib/waagent/custom-script/download/1
    time=2019-11-11T07:03:42Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event=enabled
    time=2019-11-11T07:03:42Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event=end
    Not writing a placeholder status file, already exists: /var/lib/waagent/Microsoft.Azure.Extensions.CustomScript-2.1.2/status/1.status
    + nohup /var/lib/waagent/Microsoft.Azure.Extensions.CustomScript-2.1.2/bin/custom-script-extension enable
    time=2019-11-11T08:18:02Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event=start
    time=2019-11-11T08:18:02Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event=pre-check
    time=2019-11-11T08:18:02Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="comparing seqnum" path=mrseq
    time=2019-11-11T08:18:02Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event=exit message="this script configuration is already processed, will not run again"


    I have restarted instance, upgraded instance but neither worked. Can anyone help me out how can I make extensions work on existing instances too?


    • Edited by Soumya.S Monday, November 18, 2019 6:18 AM Added logs for more clarity
    Saturday, November 16, 2019 8:19 AM

Answers

  • Hi,

    Custom script extension is designed to run only once when the extension was created. 
    Later if you need to run, Then you need to change any of the parameters passed to that script.

    In VMSS, Can you try redploy option? I think that should run the extension again.  Reimage will surely run the extension.

    You can also call the extension with forceupdate tag as shown in this document

    Please try that and let me know.

    Monday, November 18, 2019 12:01 PM

All replies

  • Hi,

    I think if you stop and start the VM from the portal, this will take effect. AFAIK, it needs to be deallocated (stopped in the portal) and started for the extension to run.

    Thanks,

    Matt

    Sunday, November 17, 2019 7:00 PM
  • Hi Matt,

    Tried stopping and starting of the instance. But not worked! logs are showing same messages

    /var/log/azure/custom-script/handler.log

    Not writing a placeholder status file, already exists: /var/lib/waagent/Microsoft.Azure.Extensions.CustomScript-2.1.2/status/1.status
    + nohup /var/lib/waagent/Microsoft.Azure.Extensions.CustomScript-2.1.2/bin/custom-script-extension enable
    time=2019-11-18T05:55:57Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event=start
    time=2019-11-18T05:55:57Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event=pre-check
    time=2019-11-18T05:55:57Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="comparing seqnum" path=mrseq
    time=2019-11-18T05:55:57Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event=exit message="this script configuration is already processed, will not run again"
    Not writing a placeholder status file, already exists: /var/lib/waagent/Microsoft.Azure.Extensions.CustomScript-2.1.2/status/1.status
    + nohup /var/lib/waagent/Microsoft.Azure.Extensions.CustomScript-2.1.2/bin/custom-script-extension enable
    time=2019-11-18T06:01:24Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event=start
    time=2019-11-18T06:01:24Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event=pre-check
    time=2019-11-18T06:01:24Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event="comparing seqnum" path=mrseq
    time=2019-11-18T06:01:24Z version=v2.1.2/git@b73cc91-clean operation=enable seq=1 event=exit message="this script configuration is already processed, will not run again"

    Monday, November 18, 2019 6:14 AM
  • Hi,

    Custom script extension is designed to run only once when the extension was created. 
    Later if you need to run, Then you need to change any of the parameters passed to that script.

    In VMSS, Can you try redploy option? I think that should run the extension again.  Reimage will surely run the extension.

    You can also call the extension with forceupdate tag as shown in this document

    Please try that and let me know.

    Monday, November 18, 2019 12:01 PM
  • Hi Jakaruna,

    By default creation of instances in vmss has set custom script extension, I have overwritten it by passing new script but then the existing instances are not picking up newly set extension.

    However Reimage is working as expected. But I doubt by performing Reimage will there be any data loss? Can I use it in prod?

    I cannot use forceupdate tag as I am working on linux.

    Thanks.

    Monday, November 18, 2019 4:23 PM
  • Hi,

    I hope you have only application code in the VMSS and the application state (database or cache) is maintainerd outside of the VMSS.  VMSS is meant to handle that kind of load.

    In that case redeploy wont affect your Application.  Also you need to update the application code right.

    In that case you need to stop the existing app , update the code and restart the application.

    During reimage also, Servers disk is replaced with new disk and then all extensiosn are executed.

    You can add the reimage operation as part of the release pipeline

    Tuesday, November 19, 2019 8:28 AM