I am trying to stop and start a Stream Analytics Job using the azure REST API via my c# program. I have been able to do this for my Data Warehouse, but am having problems now.
The documentation:
https://learn.microsoft.com/en-us/rest/api/streamanalytics/stream-analytics-job#stop
public static void PauseSAJ()
{
var request = (HttpWebRequest)WebRequest.Create("https://management.azure.com/subscriptions/" + AzureSubscriptionId + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.StreamAnalytics/streamingjobs/" + STREAMING_JOB_NAME + "/stop?api-version=2015-10-01");
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = 0;
request.Headers.Add("Authorization", "Bearer " + AuthToken);
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
System.Diagnostics.Trace.WriteLine("Stopping Streaming Analytics Job if not stopped: " + responseString);
}
The response I'm getting is: The remote server returned an error: (405) Method Not Allowed.
The documentation clearly states that the method is POST. I am using an almost exact replica of this method to stop my DW (except for the request URL) so I am confused as to why I am having problems. Is there an issue with the streamAnalytics Azure API?
According to your description, I have tested your code in my console application, with my parameters I could successfully stop my Stream Analytics Job as follows:
The response I'm getting is: The remote server returned an error: (405) Method Not Allowed.
I assumed that you could try to leverage Fiddler to collect the network trace when you executing your code, also you could just use the Composer provided by fiddler or use Postman to simulate the stop request as follows: