Stop/Start Azure Cloud Service - azure

In order to automate a process in my cloud deployment, I need to stop and start a cloud service (that archives data) very often through code. Currently, I stop and start that cloud service manually using the Azure Management Portal. I want this to be done through my another cloud service that processes the input data.
The azure cloud service that I am trying to stop and start has one deployment (PRODUCTION).
There is only limited information available in google on how to do this.
I tried the following MSDN website(Azure REST API) to toggle the deployment status between "Running" and "Suspended", but, I am getting a "Bad Request" error when I implement exactly as described in this website (MSDN does not allow me to post the website details).
Can any one of you point me to the right direction on how to stop/start azure cloud service through code?

Is this Virtual Machine? If yes, then use REST API/Powershell should do the trick
Start VM using REST API
Stop VM using REST API

Related

Azure - Schedule Webjob programmatically

I want to create a web app with node.js where users can schedule tasks that are executed on a specific time entered by the user.
I was thinking to use azure-webjobs or azure-functions for executing said tasks. I understand that scheduling in the azure portal is possible, however I couldn't find an API to schedule a webjob or function programmatically (for example using the Azure REST API).
Is it possible to schedule a azure-webjob or azure-function programmatically?
Azure WebJobs provide a more or less hidden API inside of KUDU called WebJobs API. This API is REST based webservice and it can be used to manage your jobs programmatically.
There are API endpoints available for the Azure WebJob which will be used for triggering the WebJob.
See the following documentation link for details on the list of available endpoints: https://github.com/projectkudu/kudu/wiki/WebJobs-API
Check this article: How to manage Azure WebJobs programmatically?
Also see this article might be helpful.

Azure Deploy: No Worker assigned to App Service Plan. Site Cannot Serve any requests. How To?

I'm trying to deploy my solution to Azure so my website can be accessed through the Internet.
When I deploy, Azure DevOps tells me Release/Deploy succeeds, but when I open the azurewebsties.net-URL, I get a 404.
After running some diagnostics, it tells me:
Currently no worker is assigned to the app service plan. The site cannot serve any requests.
When I research on how to Add a worker I find this link
https://learn.microsoft.com/en-us/azure-stack/operator/azure-stack-app-service-add-worker-roles?view=azs-2008&tabs=azurerm
But when I try and follow it, my azure interface is too different from theirs, and things don't add up. It says:
Azure App Service on Azure Stack Hub supports free and shared worker tiers by default.
I don't see any worker tiers at all, the tutorial-mentioned tab Roles, deals with userPermissions.
JSON resource seem to show there are no workers indeed.
But diagnostics also says following information is logged by... a worker.
Though I cannot exclude problems elsewhere for a 100%, It really seems to be a worker-problem.
Build- & ReleasePipeline succeed, Artifact get uploaded & deployed, Authentication & KeyVault is good, I get Request&Response Activity in AzurePortal-Graphs. But no website.
So my questions are:
What are these workers, what do they do high-level? Operate like some kind of ServiceBus between WebApp & Azure? What language/format are they in?
How and where can I add one? Is it in code (angular/c#), JSON or in azure portal?
Where can I find up to date documentation
Anybody know how to tackle this?
Thanks in advance!

Migrate Windows Service to Azure

We are migrating to Azure. We have a Web App deployed. However, I have a Windows Service that I need to add in to the mix. The service continuously runs, checking the associated Service Bus Queue for messages every 5 seconds.
I am looking for recommendations on how to do this.
I have looked at Web Jobs. But, I don't understand how it gets kicked off. I know there is a Web Hook involved - but I just want the code to run continuously without having to be constantly kicked.
We are also trying to avoid the cost of having a VM involved.
Thanks in advance.
Since you already have a web app, you could use a Azure App Service to run the Web App. The Azure App Service will allow you to also have a Web Job that you can have run on a schedule.
It does not make sense to break you web app into Azure Functions since it is already built. You can have the service run in an Azure Function, but it will probably add more complexity to interact with the web app (if that is what is happening) and if the service is running every 5 seconds, that could get costly.

Use Azure Mobile Service Scheduled Task to Access Azure Service Management REST Api

I am currently working on a project in which I need to accomplish the following using a scheduled task in an Azure Mobile Service (if it's possible):
Update a cloud service deployment configuration to put the cloud service into maintenance mode.
Wait a predetermined length of time for any pending work in the cloud service to complete.
Perform a backup of SQL Azure database used by the cloud service.
Wait another predetermined length of time for the backup to complete.
Update the cloud service deployment configuration to bring the cloud service out of maintenance mode.
I've got step 3 figured out already and steps 2 and 4 are relatively trivial to add. My hangup is with updating the cloud service deployment configuration using the Azure Service Management REST Api.
(I've come across no other means of doing this in a Node.js script).
The calls to the endpoint using the provided Node.js module request (example: http://msdn.microsoft.com/en-us/library/windowsazure/jj631641.aspx) are easy enough but the requests must contain a management certificate as per http://msdn.microsoft.com/en-us/library/windowsazure/ee460782.aspx
So my question is: How do I attach my management certificate to the request?
Keeping in mind that this is to be done within a scheduled task (which is a Node.js script).
Management certificate is just a standard certificate file (.cer) (X.509 v3). You can put the contents in a string (Don't kill me for suggesting this) or a table which your script would read.
Once you have the certificate content in hand as a string, you can attach it to the HTTPS request you are making to the Azure service management API. Nate Good has a nice post on how to achieve this with nodejs. He is reading the certs from files, so you'll have to change that part and replace it with your cert strings.

Is it possible to use Azure diagnostics without being in a hosted service

I have several web and worker roles in my solution, but I also have a non-Azure application running on a Azure hosted VM. That application connects to Azure storage for various things like reading and writing blobs and queues, and that works fine.
I'd like to use Azure diagnostics from within that same application (a .NET app running on a VM hosted in Azure). However, if I try to initialize diagnostics I get an exception that:
System.InvalidOperationException: Not running in a hosted service or the Development Fabric.
This makes sense, but I'm wondering if it's possible to use the diagnostics in some way without being a hosted service. In particular, I'm using azure diagnostics to gather logging information, written out by System.Diagnostics.Trace, and that's all hidden away from the application code, so if there were some other APIs I have a place I can probably slot that in.
Any ideas?
Thanks,
JC
Unfortunately, no. At least not today. The agent has some hard-coded checks for the RoleEnvironment stuff and when it is not there, it fails. This is also the reason you cannot use the agent in the IaaS stuff today either.

Resources