Oh, I see. Thanks for explaining!

@ruben, do you want to raise a pull request to update the azurecompute
readme with the missing bits? That would be highly appreciated!

(If you are up to contributing you may also want to try sending a PR
to edit the jclouds site [1] and add a page similar to the GCE [2]
user guide with the instructions for azure)


[1] https://github.com/jclouds/jclouds-site
[2] http://jclouds.apache.org/guides/google

On 19 October 2015 at 09:01, Andrea Turli <andrea.tu...@gmail.com> wrote:
> Ignasi,
>
> I think Azure provider requires the endpoint as it identifies the exact
> SUBSCRIPTION_ID you want to use.
>
> HTH,
> Andrea
>
> On Mon, Oct 19, 2015 at 6:06 AM, Ruben Rubio Rey <tk42...@gmail.com> wrote:
>>
>> Then I have the feeling that there is a bug somewhere.
>>
>> In the following code If you uncomment endpoint it works, otherwise it
>> does not.
>>
>>     @Test
>>     public void doLoginTest() throws Exception {
>>         Iterable<Module> modules = ImmutableSet.<Module> of(new
>> SshjSshClientModule(), new SLF4JLoggingModule());
>>         ComputeServiceContext context =
>> ContextBuilder.newBuilder("azurecompute")
>>                 .credentials("/path/to/azure.p12", "mysuperpassword")
>>
>> //.endpoint("https://management.core.windows.net/32a55cff-e1c5-435f-9343-MYENDPOINT";)
>>                 .modules(modules)
>>                 .buildView(ComputeServiceContext.class);
>>         ComputeService compute = context.getComputeService();
>>         Set<? extends Hardware> jHardwares =
>> compute.listHardwareProfiles();
>>         System.out.print(jHardwares);
>>     }
>>
>> This is the error:
>>
>> 15:02:09.232 [main] DEBUG o.j.rest.internal.InvokeHttpMethod - >> invoking
>> ListRoleSizes
>> 15:02:09.247 [main] DEBUG o.j.h.i.JavaUrlHttpCommandExecutorService -
>> Sending request -702374286: GET
>> https://management.core.windows.net/SUBSCRIPTION_ID/rolesizes HTTP/1.1
>> 15:02:09.250 [main] DEBUG jclouds.headers - >> GET
>> https://management.core.windows.net/SUBSCRIPTION_ID/rolesizes HTTP/1.1
>> 15:02:09.251 [main] DEBUG jclouds.headers - >> x-ms-version: 2014-10-01
>> 15:02:09.252 [main] DEBUG jclouds.headers - >> Accept: application/xml
>> 15:02:12.497 [main] DEBUG o.j.h.i.JavaUrlHttpCommandExecutorService -
>> Receiving response -702374286: HTTP/1.1 403 Forbidden
>> 15:02:12.498 [main] DEBUG jclouds.headers - << HTTP/1.1 403 Forbidden
>> 15:02:12.498 [main] DEBUG jclouds.headers - << Date: Mon, 19 Oct 2015
>> 04:02:11 GMT
>> 15:02:12.499 [main] DEBUG jclouds.headers - << Server:
>> Microsoft-HTTPAPI/2.0
>> 15:02:12.500 [main] DEBUG jclouds.headers - << Content-Type:
>> application/xml; charset=utf-8
>> 15:02:12.500 [main] DEBUG jclouds.headers - << Content-Length: 288
>> 15:02:12.514 [main] DEBUG jclouds.wire - << "<Error
>> xmlns="http://schemas.microsoft.com/windowsazure";
>> xmlns:i="http://www.w3.org/2001/XMLSchema-instance";><Code>ForbiddenError</Code><Message>The
>> server failed to authenticate the request. Verify that the certificate is
>> valid and is associated with this subscription.</Message></Error>"
>>
>> PS_ How does JClouds knows what subscription is the correct one if the
>> .cer file is uploaded to two or more subscriptions ?
>>
>> On Sun, Oct 18, 2015 at 7:02 PM, Ignasi Barrera <n...@apache.org> wrote:
>>>
>>> Good to see you made progress! Just one little thing: the endpoint
>>> shouldn't be required when creating the context for Azure (or any
>>> "provider").
>>>
>>> As opposed to generic APIs [1] like OpenStack or CloudStack, Azure is a
>>> concrete provider with a well-known endpoint, so jclouds will already
>>> configure it for you.
>>>
>>> [1] http://jclouds.apache.org/start/concepts/
>>>
>>> I.
>>>
>>> El 18/10/2015 3:05, "Ruben Rubio Rey" <tk42...@gmail.com> escribió:
>>> >
>>> > Hi Ignasi,
>>> >
>>> > Thanks so much for your response. It has been very helpful. The hardest
>>> > thing was to get the authentication right, so for future references I 
>>> > would
>>> > like to send the following code instructios:
>>> >
>>> > 1 - Add azurecompute into the pom.xml
>>> > 2 - Generate the certificate (will create the pem, cert, p12 files and
>>> > the P12_EXPORT_PASSWORD)
>>> > 3 - Upload to Azure portal (I used the old portal, I could not find the
>>> > option in the new one)
>>> > 4 - The following code will authenticate and get the Compute Service.
>>> >
>>> > ComputeServiceContext context =
>>> > ContextBuilder.newBuilder("azurecompute")
>>> >         .credentials("/path/to/azure.p12", "P12_EXPORT_PASSWORD")
>>> >
>>> > .endpoint("https://management.core.windows.net/6ac5048e-6e83-4c99-a1a8-YOUR-SUSBCRIPTION-ID";)
>>> >         .modules(modules)
>>> >         .overrides(overrides)
>>> >         .buildView(ComputeServiceContext.class);
>>> > ComputeService computeService = context.getComputeService();
>>> >
>>> > Thanks for guiding me into the right direction.
>>> >
>>> > Regards,
>>> > Ruben
>>> >
>>> >
>>> > On Fri, Oct 16, 2015 at 8:36 AM, Ignasi Barrera <n...@apache.org>
>>> > wrote:
>>> >>
>>> >> Hi!
>>> >>
>>> >> The way you start instances in Azure is the same in all providers.
>>> >> jclouds provides a portable layer you can use to create instances in
>>> >> different clouds using the same code. I recommend you read the
>>> >> "compute getting started guide" [1] to have a better understanding of
>>> >> how it works.
>>> >>
>>> >> You can also try the compute-basics example [2]. The code is simple
>>> >> and to the point, and you can compile and run it to deploy also on
>>> >> azure (although you'll need to explicitly add the azurecompute
>>> >> dependency to the pom.xml). Have a look at the azurecompute readme [3]
>>> >> for the details on how to generate the credentials and what identity
>>> >> and credential jclouds expects.
>>> >>
>>> >> HTH!
>>> >>
>>> >> I.
>>> >>
>>> >>
>>> >> [1] http://jclouds.apache.org/start/compute/
>>> >> [2]
>>> >> https://github.com/jclouds/jclouds-examples/tree/master/compute-basics
>>> >> [3] https://github.com/jclouds/jclouds-labs/tree/master/azurecompute
>>> >>
>>> >> On 14 October 2015 at 11:03, Ruben Rubio Rey <tk42...@gmail.com>
>>> >> wrote:
>>> >> > Hi Everyone,
>>> >> >
>>> >> > I am exploring the capabilities for Azure but azurecompute still
>>> >> > under
>>> >> > development. As far I understand we should use AzureComputeApi.
>>> >> >
>>> >> > Could anyone please tell me how to create a new instance using
>>> >> > AzureComputeApi ?
>>> >> >
>>> >> > Regards,
>>> >> > Ruben
>>> >> >
>>> >
>>> >
>>
>>
>

Reply via email to