Is there a REST API call for Azure Mobile Service's Scheduler Run Once? - rest

Using the Azure portal, I can click the Run Once button on a Scheduler job to execute it. Is that functionality available via a REST call from my app? The scenario is that periodically a job is run to check for changes in data. The first time the app starts up, I would like to execute that job once as not to have to wait for the scheduled time.
What is the call to kick off a scheduled job? Would I have to duplicate code in both the scheduler job and custom API and then call the custom API from my code?

You can execute a scheduler job by sending a POST request to /jobs/<jobName> (no request body required). But you need to pass the master key of your mobile service (in the x-zumo-master HTTP header), so you should only do that from a location that is not visible to your users - you don't want anyone getting a hold of your master key, as this would open up your service for all kinds of attacks.

Related

Azure DevOps ServiceHooks: Run Job state changed webhook

I am trying to use the service hook of azure devops, and while applying the the filter “Run Job state changed webhook”.
The pipeline running contains 8 jobs and when their states change none of them triggers the webhook and there is no attempt in the history of the pipeline. However when trying to test the service hook using the “Test” button, the attempt succeeds and the request is received normally.
Any ideas what might be the root cause of the problem and how to fix it?
Thanks in advance

Attempting to instantiate Dataproc workflow via Cloud Scheduler results in INVALID_ARGUMENT

I have an existing, functional Dataproc workflow template, and I am attempting to create a Cloud Scheduler job to run it on a schedule. The workflow template runs without error when run via the "RUN" button on the Dataproc Workflow Template console page.
I created a Scheduler job to run this workflow template with the following command (names redacted here):
gcloud scheduler jobs create http <job-name>
--location=us-central1
--schedule="0 1 * * *"
--http-method=POST
--uri=https://dataproc.googleapis.com/v1/projects/<project-name>/regions/us-central1/workflowTemplates/<template-name>:instantiate?alt=json
--oauth-service-account-email=<service-account-name>#<project-name>.iam.gserviceaccount.com
--oauth-token-scope=https://www.googleapis.com/auth/cloud-platform
The job is successfully created, but upon attempting to run it, it returns INVALID_ARGUMENT. Here is the response:
{"#type":"type.googleapis.com/google.cloud.scheduler.logging.AttemptFinished", "jobName":"projects/<project-name>/locations/us-central1/jobs/<job-name>",
"status":"INVALID_ARGUMENT", "targetType":"HTTP", "url":"https://dataproc.googleapis.com/v1/projects/<project-name>/regions/us-central1/workflowTemplates/<workflow-name>:instantiate?alt=json"}
I get no more descriptive response than that. There is no sign the workflow began, nor any failures listed on the Dataproc Workflow console page.
I also tried a similar Scheduler job with the same service account, scope, location, and schedule, but I cut the URL down to the base workflow location: https://dataproc.googleapis.com/v1/projects/<project-name>/regions/us-central1/workflowTemplates/<template-name> and tried --http-method=GET, and that was successful, but, of course, does not instantiate the workflow.
Is there either something I'm missing, or is there at least a better way to diagnose the issue?
I have now been able to successfully kick off this workflow via Scheduler once the Service Account User role has been added to the service account that is used in creating the Scheduler job. That is, the service account itself also needs to be a service account user.

Azure DevOps : Error Message The Service Hooks service was unable to send the notification to the target consumer

​We have created some service hooks in Azure DevOps which get triggered during as soon our Release Pipeline is succeeded. However, we have noticed that these service hooks fail abruptly with the message. To give a context, the Service Hook executes a custom API which in turn calls a bunch on Azure DevOps REST APIs.
Error Message The Service Hooks service was unable to send the
notification to the target consumer. Error Details Object reference
not set to an instance of an object. (activity Id is
f928eefe-3eaa-0000-6bc9-8f832ebdd601).
We do not have any further information apart from the one mentioned above. We are trying to understand under what circumstance this can happen. Can somebody throw some light as to what might lead to issues like this one?

How to run one release at time on Azure DevOps?

I am to implement pre-deployment gates on my azure devops release.
I am using HTTP request gate to check each time if there is ongoing deployment.
The problem is, when deployment on one release finishes (stage 1 ), I want to prevent the deployment on next release in queue if there is (stage 2) to the pipeline that does not do deployment for example.
The end goal is, no matter how many releases in queue I have and no matter how many agents in my pool, I want to make sure that release start only if there is no other active release in deployment/other stages.
You can add a gate of Invoke REST API: GET to call below Deployments - List rest api and check if there are any releases in deployment. See below steps:
https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/deployments?operationStatus=queued,queuedForAgent,phaseInProgress&api-version=6.1-preview.2
1, Add a Invoke Rest Api Gate
Go to Pre-deployment conditions --> Enable Gate-->Add a Invoke Rest Api Gate-->Click Manage to create a service connection. See below screenshot.
2, Create a service connection shown in above screenshot.
When you Click Manage in above screenshot. You will be forward to service connections page. Click new service connection and select Generic type of service connection:
The server Url: https://vsrm.dev.azure.com/{Org}/{Proj}
Password: Personal Access Token
3, Go back to the Invoke Rest Api Gate. Select the service connection just created: See below
Method: Get
URL suffix and parameters: /_apis/release/deployments?operationStatus=queued,queuedForAgent,phaseInProgress&api-version=6.1-preview.2
Success criteria: eq(root['value'][0], '')
Above Invoke rest api gate will call the deployments list rest api to filter these releases that are inProgress or queued of deployment using operationStatus filter(ie. operationStatus=queued,queuedForAgent,phaseInProgress). If the there is any deloyment is inProgress or queued the Success criteria: eq(root['value'][0], '') will failed.
If you using self-hosted agents and Environments. You can check the Exclusive lock on Environments and Agent pools.

How to use Webhooks in rundeck to send status of the job executed

Completely new to Webhook concept and Rundeck. I have a job in rundeck where it checkes health of some servers, code being in python.
Fetch 200 Ok status after running Curl Command and using that status write a condition using python in RUNDECK
i want to use webhook to provide update via email/slack channel to 5-6 users
Created a webhook, i selected a job which it should invoke, but i didnt understand what options to be entered options section[Job Option arguments, in the form -opt1 value -opt2 "other value"]
when i click on the webhook URL it gives 404 error found.
this might be the very basic questions. sorry kindly help
i want to use webhook to provide update via email/slack channel to 5-6 users
Webhooks are used to enable third-party applications to trigger jobs. If you just want to send notifications of job status when a job is run, you don't need to use a webhook.
When you configure the job there's a "Notifications" tab. You can select when and how to send notifications. For slack specifically, there is a notification plugin you can install.
To pass options to webhook you need to pass it in this way. Here you have a good example to integrate it with python code.
UPDATE: Anyway, this answer is the way to achieve your goal.