2
votes

I'm trying to make some calls to the new Azure Scheduler API. However, all my requests come back with this error:

<Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <Code>AuthenticationFailed</Code>
  <Message>The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription.</Message>
</Error>

I'm pretty sure that I have everything setup correct because I can make calls using the same code and certificate to the Azure Service Management API.

The code I'm using to attach the certificate to the web request is from the MSDN Sample. The Scheduler API calls that I've tried to make are the Check Name Availability, Create Cloud Service, and Create Job Collection.

I've also verified that my subscription is Active for the preview of the Scheduler.

Here is an example of a request I've tried:

Create Cloud Service

Request A cloud service is created by submitting an HTTP PUT operation to the CloudServices OData collection of the Service Management API Tenant.Replace with your subscription ID and with your cloud service ID.

So for this I create a web request pointing to:

https://management.core.windows.net/[MySubId]/cloudServices/[MyNewServiceName]

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestUri);

// Define the requred headers to specify the API version and operation type.
request.Headers.Add("x-ms-version", "2012-03-01");
request.Method = "PUT";
request.ContentType = "application/xml";

Next I add the request body as specified in the documentation:

<CloudService xmlns:i='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://schemas.microsoft.com/windowsazure'>
  <Label>[MyServiceName]</Label>
  <Description>testing</Description>
  <GeoRegion>uswest</GeoRegion>
</CloudService>

And finally I add the certificate that I use with my subscription to the account.

// Attach the certificate to the request.
request.ClientCertificates.Add(certificate);

I try to get the response and instead I get the error shown above.

BTW - I've also tried different regions thinking maybe it was a region issue since the scheduler isn't supported in all regions, but I still get the same response.

1
Hey Bryant, which call did you try to make, and what exact URI did you send a request to? If you can share full headers & body of the request, that'll help!krisragh MSFT
Sure, I can post those. Which method call would be the simplest to troubleshoot?Bryant
Can you check if there's a trailing slash "/" in your request URL? I've been playing with REST API and I am able to create cloud services without any issues. I get same error if I put a trailing slash in my request URL.Gaurav Mantri

1 Answers

0
votes

You need to register the scheduler in your application first by calling (PUT):

<subscription id>/services?service=scheduler.JobCollections&action=register

If you want to do this in .NET you can use the new Management libraries:

var schedulerServiceClient = new SchedulerManagementClient(credentials);
var result = schedulerServiceClient.RegisterResourceProvider();

Console.WriteLine(result.RequestId);
Console.WriteLine(result.StatusCode);
Console.ReadLine();

More detail: http://fabriccontroller.net/blog/posts/a-complete-overview-to-get-started-with-the-windows-azure-scheduler/