Can I start and stop the azure website on a schedule automatically?

Even asking this question, I wonder how something so complicated can be so difficult for me. All I want to do is automate the scheduled shutdown and start of Azure WebSite. First I looked at WebJobs and created a powershell script file that would stop WebSite, which used the stop-azurewebsite cmdlet:

stop-azurewebsite [my site]

Then I created a .cmd file to call it with powershell.exe to execute the powershell file

PowerShell.exe -ExecutionPolicy RemoteSigned -File stopit.ps1

I created WebJob to run the powershell command to stop the site, but it made a mistake with the message:

stop-azurewebsite : The term 'stop-azurewebsite' is not recognized as the name 
of a cmdlet, function, script file, or operable program. Check the spelling of 
the name, or if a path was included, verify that the path is correct and try 
again.

So, I decided that I would go on the REST API route. I made a send request using the violinist and the appropriate management certificate to call:

https://management.core.windows.net/[my subscription id]/services/WebSpaces/[webspace]/sites/[website name]/stop

, "" . "", . , , , ( ) Azure WebSite ?

UPDATE:

, http, , PUT

https://management.core.windows.net/[my subscription id]/services/WebSpaces/[webspace]/sites/[website name] {"State":"Stopped"}, "PUT`ing" URL- WebJob.

+4
3

Azure Automation, , "Running" -/webapps .

# Get Websites/webapps
$websites = Get-AzureWebsite | where-object -FilterScript{$_.state -eq 'Running' }

# Stop each website
foreach -parallel ($website In $websites)
{
    $result = Stop-AzureWebsite $website.Name
    if($result)
    {
        Write-Output "- $($website.Name) did not shutdown successfully"
    }
    else
    {
        Write-Output "+ $($website.Name) shutdown successfully"
    }
}

, Azure Portal. , , , .

-/- "" "" "-AzureWebsite" "Start-AzureWebsite".

+6

Azure Automation. Powershell , // .

0
0
source

All Articles