1
votes

Trying to invoke two webhooks that I've defined on a runbook in an azure automation account.

I can run the webhook through powershell, and it works, but i'm having trouble getting it to run. Below is the code i'm using

<HTML>
<TITLE>Jumpbox Power</TITLE>
<BODY>
<CENTER>


<SCRIPT>
function startjumpbox() {
    var _url = 'https://s5events.azure-automation.net/webhooks?token=asdf;
    return $.ajax({
        type: 'post',
        url: _url
    })
};

function startjumpbox() {
 var _url = 'https://s5events.azure-automation.net/webhooks?token=fdsa';
 return $.ajax({
     type: 'post',
     url: _url
 })
};
</SCRIPT>

Start / Stop jumpbox<br>
<button onclick="startjumpbox()">Start Jumpbox</button> 
<button onclick="stopjumpbox()">Stop Jumpbox</button
</CENTER>
</BODY>
</HTML>

The idea is that when the first button is pressed, the 'startjumpbox' function is run, which generates a post request to the webhook URL. same goes for the second button and a post to the second webhook URL. Would appreciate any advise.

1
You just wanna start the 2 runbooks? - Ivan Yang

1 Answers

1
votes

Please use the code below. It works at my side, just reference the jquery lib(You can also download it to local and then reference it):

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

sample code:

<!DOCTYPE html>
<HTML>
<head>
<TITLE>Jumpbox Power</TITLE>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<BODY>

<SCRIPT>
function startjumpbox() {
    alert("start call 1")
    var _url = 'https://s4events.azure-automation.net/webhooks?token=your_token';
    $.ajax({
        type: 'POST',
        url: _url
    });
    alert("completed call 1")
}

function startjumpbox2() {
    alert("start call 2")
    var _url = 'https://s4events.azure-automation.net/webhooks?token=your_token';
    $.ajax({
        type: 'POST',
        url: _url
    });
    alert("completed call 2")
}
</SCRIPT>

Start / Stop jumpbox<br>
<button onclick="startjumpbox()">Start Jumpbox</button> 
<button onclick="startjumpbox2()">Start Jumpbox2</button>
</BODY>
</HTML>