none
How to set application pool recycle period when deploy to cloud service? RRS feed

  • Question

  • Hi 

    I want to set application pool recycle period with cloud service. I have 2 question.

    Question1:

    I follow below startup-tasks-common:

    https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-startup-tasks-common

    and try use this cmd to change recycle period:

    appcmd.exe set config -section:system.applicationHost/applicationPools /+"[name='xxxx'].recycling.periodicRestart.schedule.[value='03:00:00']" /commit:apphost

    I can run above cmd on remote cmd prompt successfully.

    But the problem is , when i deploy to cloud service, the application pool name is a GUID, which is random generated,

    I dont know how to set the recycle period without the app pool name, i find an cmd below:

    appcmd set config -section:applicationPools -applicationPoolDefaults.recycling.periodicRestart.schedule.[value='00:12:00'] /commit:apphost 

    but i got this error:  ERROR ( message:Cannot find requested collection element. )

    I cannot find any document mention how to set recycle period without the app pool name/ with Azure cloud service. 

    How to set the recycle period when deploy to cloud service?

    Question 2:

    How can i config run the cloud service startup task depend on the environment / depoly profile. 

    for example, can we have something like ServiceDefinition.development.csdef , ServiceDefinition.UAT.csdef ,ServiceDefinition.production.csdef , so i can set up the recycle period depend on the environment.

    Many Thanks

    Grace

    Wednesday, January 30, 2019 7:16 AM

Answers

  • Thanks for your reply. Micah.

    Finally i directly got the answer from Microsoft Azure support. The command i used has little mistake.

    Now i can use below cmd to do so in cloud service:

    appcmd.exe set config -section:system.applicationHost/applicationPools /+"applicationPoolDefaults.recycling.periodicRestart.schedule.[value='03:00:00']" /commit:apphost



    • Marked as answer by Grace Chan Thursday, March 14, 2019 9:37 AM
    • Edited by Grace Chan Thursday, March 14, 2019 10:19 AM
    Thursday, March 14, 2019 9:37 AM

All replies

  • As you mentioned I am also not finding much on application recycling for Cloud Services. I am not sure this is something you need to implement yourself when running cloud services. This is actually the first times I have heard this topic brought up for Cloud Services. 

    I only found a few official docs on recycling:

    https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-application-and-service-availability-faq

    https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-troubleshoot-common-issues-which-cause-roles-recycle

    Can you tell me a bit more about your end goal for your Cloud Service? 


    Wednesday, January 30, 2019 8:56 PM
    Moderator
  • Thanks for your reply. Micah

    In iis application pool, it will auto recycle after several time (not fixed, not sure):

    https://docs.microsoft.com/en-us/iis/configuration/system.applicationhost/applicationpools/add/recycling/

    i want it recycle by schedule. e.g every 8:00 AM

    In normal window computer, you can open iis manager, right click you pool to set the schedule:

    

    or you can use appcmd in cmd prompt to do so:

    appcmd.exe set config -section:system.applicationHost/applicationPools /+"[name='xxxx'].recycling.periodicRestart.schedule.[value='03:00:00']" /commit:apphost

    In cloud service, i can remote to vm and set schedule manually.

    But, i don't want to do it manually, as every time i deploy my service, i need to do it again.

    So, i finding a method i can set the app pool recycle schedule automatically during deployment.

    And i find this (cloud-services-startup-tasks-common):

    https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-startup-tasks-common

    this allow server to run cmd script during service startup. so i can use appcmd.exe to set schedule .

    However, to use appcmd set schedule, you need to know application pool name,

    But the app pool name in cloud service is a GUID, which random generated.

    So, i can not use appcmd, because i don't know the app bool name wt will generated.

    I find another cmd, it seems use default app pool that no need to know the pool name:

    appcmd set config -section:applicationPools -applicationPoolDefaults.recycling.periodicRestart.schedule.[value='00:12:00'] /commit:apphost 


    but i got this error:  ERROR ( message:Cannot find requested collection element. ) 

    Is there any other way to set iis application pool recycle schedule?Thanks 

    Thursday, January 31, 2019 3:05 AM
  • Thanks for the extra details. I understand what you are trying to do. 

    As you mentioned, the simplest way to do this will be by manually logging into the VM and setting this. As cloud service is a classic resource some management and automation options you have available are limited. 

    The only way I can think of possibly automating this might be to pull the GUID using the classic REST API

    https://docs.microsoft.com/en-us/previous-versions/azure/reference/ee460812(v%3dazure.100)

    If you can pull that GUID you could store the variable and apply the settings automatically. 

    Without getting that information I don't see a way to automate this. 

    As a side note, have you considered going down the App Services route instead of Cloud Services? This might make it easier to manage your sites and give you more automation options 

    https://docs.microsoft.com/en-us/azure/app-service/

    • Proposed as answer by Dave RendónMVP Wednesday, February 13, 2019 4:45 AM
    Thursday, January 31, 2019 8:58 PM
    Moderator
  • Thanks for your reply. Micah.

    Finally i directly got the answer from Microsoft Azure support. The command i used has little mistake.

    Now i can use below cmd to do so in cloud service:

    appcmd.exe set config -section:system.applicationHost/applicationPools /+"applicationPoolDefaults.recycling.periodicRestart.schedule.[value='03:00:00']" /commit:apphost



    • Marked as answer by Grace Chan Thursday, March 14, 2019 9:37 AM
    • Edited by Grace Chan Thursday, March 14, 2019 10:19 AM
    Thursday, March 14, 2019 9:37 AM