You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by Teo De Las Heras <te...@microsoft.com> on 2017/01/04 20:36:15 UTC

RE: Example end-to-end walkthrough?

Thanks for the replies.  Apologies for the n00b questions that follow…from what I've read, is my understanding below correct:

  *   Pom.xml is used by mvm to download the necessary jclouds binaries?
     *   http://jclouds.apache.org/start/install/
        *   Mvn dependency:copy-dependencies
     *   Maybe it’s just is an mvn / java ‘preference’ (which I don’t have a lot of experience with) but there doesn't seem to be consistency in the examples for how this should 'run'.
        *   The compute basics example: https://github.com/jclouds/jclouds-examples/tree/master/compute-basics
        *   Says to run mvn install and then java -jar … and never mentions running mvn dependency:copy-dependencies
        *   The Azure ARM example: https://github.com/jclouds/jclouds-labs/tree/master/azurecompute-arm
        *   Says to run mvn -DTest … DTest isn’t in the Maven documentation:
           *   https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
           *   Why would mvn install be needed in the compute basics but not the Azure ARM example?
  *   Once Pom.xml is ‘processed’ by mvn, I can build a .jar file that uses the jclouds API’s?
     *   http://jclouds.apache.org/start/compute/
        *   Java -jar …
     *   Again, maybe this is just an mvn / Java preference but why doesn’t the Azure ARM example show this?  Instead it just shows mvn



Thank you,



Teo De Las Heras



-----Original Message-----
From: Ignasi Barrera [mailto:nacx@apache.org]
Sent: Thursday, December 29, 2016 4:58 PM
To: user@jclouds.apache.org
Cc: Teo De Las Heras <te...@microsoft.com>
Subject: Re: Example end-to-end walkthrough?



Trying to understand the compute basics examples is one of the better ways to get started with jclouds.



There are two different Azure providers in jclouds:



* The "azurecompute" one uses the old Azure API.

* The "azurecompute-arm" uses the new ARM API.



You'll need to add the "org.apache.jclouds.labs/azurecompute" or "org.apache.jclouds.labs/azurecompute-arm" dependencies to your project in order to use them.



In the README for the azurecompute-arm provider you will find the instructions to create an Application in your subscription for

jclouds:

https://github.com/jclouds/jclouds-labs/tree/master/azurecompute-arm



You might also find the following talks useful:

https://speakerdeck.com/nacx/rule-the-cloud-with-apache-jclouds

http://feathercast.apache.org/apachecon-na-2016-rule-the-cloud-with-apache-jclouds-ignasi-barrera/

(audio recording for the talk)

https://github.com/nacx/acna2016-demo (simple source code for the demo)



https://speakerdeck.com/nacx/introduction-to-apache-jclouds-apachecon-eu-2014





HTH!



I.



On 23 December 2016 at 20:20, Andrew Phillips <ap...@qrmedia.com>> wrote:

> Hi Teo

>

> The jclouds-examples repo [1] may help - I don't think it has an

> Azure-specific example at present, but the general "compute-basics"

> app should hopefully give a better idea of how the end-to-end flow

> might look

> like:

>

> https://github.com/jclouds/jclouds-examples/blob/master/compute-basics

> /src/main/java/org/jclouds/examples/compute/basics/MainApp.java

>

> It uses the jclouds' compute abstraction, but should also work with

> the Azure providers.

>

> Of course, suggestions and/or PRs for ways we can improve the initial

> "how does this all fit together?" documentation are also much

> appreciated - definitely things we can do there.

>

> Regards

>

> ap

>

> [1] https://github.com/jclouds/jclouds-examples/

Re: Example end-to-end walkthrough?

Posted by Ignasi Barrera <na...@apache.org>.
>
> Thanks.  I got the same suggestion from the team that created the ARM
> project.  I’ve almost got it running.  How would I figure out what
> parameters are needed / what can be overwritten?  Not sure how I would have
> known to use -Dazurecompute-arm.endpoint.  I see it in the
> azurecompute-arm project but it’s not clearly spelled out that it should be
> added when calling the compute service API.
>

There are some common properties and some provider-specific ones.
Unfortunately we don't have yet a page describing all the existing ones.
You can find the common properties here:
http://jclouds.apache.org/reference/javadoc/2.0.x/org/jclouds/Constants.html
The compute service specific properties here:
http://jclouds.apache.org/reference/javadoc/2.0.x/org/jclouds/compute/config/ComputeServiceProperties.html
And each provider often has a constants class with all its particular
properties. In the case of azurecompute-arm:
https://github.com/jclouds/jclouds-labs/blob/master/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeProperties.java


>
> Another question on getting the project to run.  I’m getting errors below
> about not finding images in default storage account and machine not found.
> I think I probably need to modify the code in the MainApp.Java, yes?
>

This is an expected behaviour when you have existing virtual machines, and
it is just a warning log message. The jclouds compute service has an
ImageExtension that allows users to create images (or snapshots) of
existing virtual machines. In Azure, those images are stored in the storage
account of the virtual machine itself, and the only way to list them is to
inspect the storage account of each existing VM. That's why the
"listImages" operations tries to access each VM's storage account, and why
you might see the warning message, if access there is denied. Under normal
circumstances you can safely ignore that message.


> Based on what I’m reading here, http://jclouds.apache.org/start/compute/
> , I think I should modify the templateBuilder object to get around the
> errors below?  Just not sure what to enter.  For example, how do I override
> the default location which seems to be eastasia?    The azurecompute-arm
> project says I can do jclouds.regions="northeurope" but not sure where to
> put that.
>

There are two different things here.

First, the "jclouds.regions" property is used to filter the regions jclouds
will take into account. By default, jclouds will connect to each region and
list images, VMs, etc, from all them. This can be time consuming, and
probably you don't want to work with all existing regions. That property
allows you to tell jclouds which regions you care about, so it does not try
to connect and get information from the rest. If you don't set it, all
regions will be considered by default.

The other thing is about selecting the location where the VM will run. This
can be set with the "templateBuilder.locationId" method, but if omitted,
jclouds will select one location that is compatible with the selected image
and hardware profile. AFAIK it is not the case of ARM, but some providers
don't have all hardware profiles (and/or images) available in all regions,
so jclouds makes sure to select a location where the selected
image/hardware pair can run.


> -Multiple entries with same key
>
> >Not sure what this means.  The only time I’ve seen key mentioned in the
> documentation is in relation to SSH keys.
>
>
> error: Multiple entries with same key: Standard_A0={id=Standard_A0,
> providerId=Standard_A0, name=Standard_A0, location={scope=REGION,
> id=southeastasia, description=Southeast Asia, parent=azurecompute-arm,
> iso3166Codes=[SG]}, processors=[{cores=1.0, speed=2.0}], ram=768,
> volumes=[{type=LOCAL, size=20480.0, bootDevice=false, durable=false},
> {type=LOCAL, size=1047552.0, bootDevice=false, durable=false}],
> supportsImage=ALWAYS_TRUE, userMetadata={maxDataDiskCount=1}} and
> Standard_A0={id=Standard_A0, providerId=Standard_A0, name=Standard_A0,
> location={scope=REGION, id=eastasia, description=East Asia,
> parent=azurecompute-arm, iso3166Codes=[HK]}, processors=[{cores=1.0,
> speed=2.0}], ram=768, volumes=[{type=LOCAL, size=20480.0, bootDevice=false,
> durable=false}, {type=LOCAL, size=1047552.0, bootDevice=false,
> durable=false}], supportsImage=ALWAYS_TRUE, userMetadata={
> maxDataDiskCount=1}}
>

This is the first time I see this error. Do you have a complete stacktrace?


HTH!



>
>
>
>
>
>
> *From:* Ignasi Barrera [mailto:nacx@apache.org]
> *Sent:* Saturday, January 7, 2017 5:17 AM
>
> *To:* user@jclouds.apache.org
> *Subject:* Re: Example end-to-end walkthrough?
>
>
>
> Good to see you progressed!
>
> You're almost there. The error you are getting is because the Azure ARM
> provider needs some additional configuration properties.
>
> As you might have already seen, when creating the jclouds context you can
> pass a set of configuration properties. This is done here [1] in the
> compute-basics example app, but jclouds also loads them from the system
> properties. You could use this to pass the additional properties when
> executing the jar file.
>
> The additional properties you need to set are:
>
> * azurecompute-arm.endpoint (because the endpoint is not fixed as it
> contains the subscription id).
> * oauth.endpoint (because it is not fixed as it contains the tenant id).
>
> You can follow the steps described in the Azure ARM README [2] to create
> an application you can use for jclouds. Once you have it, you should be
> able to run the examples with a command similar to:
>
> java  -Dazurecompute-arm.endpoint="https://management.azure.com/
> subscriptions/<Subscription-id>" \
>     -Doauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token"
> \
>     -jar target/compute-basics-jar-with-dependencies.jar \
>
>     azurecompute-arm <Application-Id> <Password> mygroup add
>
>
> HTH!
>
>
>
> P.S. If you want to contribute or help improve the jclouds site, you can
> have a look at our "How to contribute documentation" guide [3]. Also, it
> would be great if you could add, once you manage to run the examples with
> Azure, the example command to the compute-basics README [4]. That will help
> other future users.
>
>
>
>
> [1] https://github.com/jclouds/jclouds-examples/blob/master/
> compute-basics/src/main/java/org/jclouds/examples/compute/
> basics/MainApp.java#L267-L271
> [2] https://github.com/jclouds/jclouds-labs/tree/master/
> azurecompute-arm#setting-up-test-credentials
>
> [3] https://cwiki.apache.org/confluence/display/JCLOUDS/How+to+Contribute+
> Documentation
>
> [4] https://github.com/jclouds/jclouds-examples/blob/
> master/compute-basics/README.md
>
>
>
> On 6 January 2017 at 23:42, Teo De Las Heras <te...@microsoft.com>
> wrote:
>
> I'm getting an error (below) and following up with the creators of the
> azurecompute-arm libraries.
>
> Documentation feedback: I'd be happy to write up / contribute a 'jclouds
> for dummies' page.  I'm sure it's easy for someone who understands or works
> with Maven / Java projects.  Without that background, it's hard to decipher
> how all the pieces work together.  Or maybe some additional links to
> relevant Maven documentation that explains what mvn install does, what
> pom.xml is for, how to add dependencies (to use jclouds-labs).
>
> Error I'm getting:
> java -jar target/compute-basics-jar-with-dependencies.jar
> azurecompute-arm <my application id> <mypassword> mygroup add
> >> initializing {id=azurecompute-arm, name=Microsoft Azure Resource
> Manager REST API, views=[org.jclouds.compute.ComputeServiceContext],
> endpointName=Resource Manager Endpoint ending in your Subscription Id,
> identityName=Azure Service Principal Application Id,
> credentialName=Optional.of(Azure Service Principal Application Password),
> documentation=https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx,
> api=interface org.jclouds.azurecompute.arm.AzureComputeApi}
> Exception in thread "main" com.google.inject.CreationException: Guice
> creation errors:
>
> 1) No implementation for java.lang.String annotated with
> @com.google.inject.name.Named(value=oauth.endpoint) was bound.
>   at org.jclouds.oauth.v2.config.OAuthModule.oauthEndpoint(
> OAuthModule.java:63)
>
> 1 error
>         at com.google.inject.internal.Errors.
> throwCreationExceptionIfErrorsExist(Errors.java:435)
>         at com.google.inject.internal.InternalInjectorCreator.
> initializeStatically(InternalInjectorCreator.java:154)
>         at com.google.inject.internal.InternalInjectorCreator.build(
> InternalInjectorCreator.java:106)
>         at com.google.inject.Guice.createInjector(Guice.java:95)
>         at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.
> java:405)
>         at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.
> java:328)
>         at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:615)
>         at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:595)
>         at org.jclouds.examples.compute.basics.MainApp.
> initComputeService(MainApp.java:292)
>         at org.jclouds.examples.compute.basics.MainApp.main(MainApp.
> java:141)
>
>
> Teo
>
>
>
> -----Original Message-----
> From: Andrew Phillips [mailto:aphillips@qrmedia.com]
> Sent: Friday, January 6, 2017 3:25 PM
> To: user@jclouds.apache.org
> Subject: Re: Example end-to-end walkthrough?
>
> > I was completely confused by being directed to the github for the
> > azurecompute-arm as I thought that was an example I should be
> > following.
>
>
> Thanks for the update! Are things working now, or is there still something
> that's not doing what it should?
>
> Also, do you have any thoughts on what we could do to make the
> documentation clearer?
>
> ap
>
>
>

RE: Example end-to-end walkthrough?

Posted by Teo De Las Heras <te...@microsoft.com>.
Thanks.  I got the same suggestion from the team that created the ARM project.  I’ve almost got it running.  How would I figure out what parameters are needed / what can be overwritten?  Not sure how I would have known to use -Dazurecompute-arm.endpoint.  I see it in the azurecompute-arm project but it’s not clearly spelled out that it should be added when calling the compute service API.

Another question on getting the project to run.  I’m getting errors below about not finding images in default storage account and machine not found.  I think I probably need to modify the code in the MainApp.Java, yes?
Based on what I’m reading here, http://jclouds.apache.org/start/compute/ , I think I should modify the templateBuilder object to get around the errors below?  Just not sure what to enter.  For example, how do I override the default location which seems to be eastasia?    The azurecompute-arm project says I can do jclouds.regions="northeurope" but not sure where to put that.

My questions on the errors:
-could not get custom images from storage account
>Why is it looking for a custom image and why in my storage account / container?  I’m guessing this is part of the ARM project but not sure how to override this?  templateBuilder still?

-image with id /subscriptions/fed7f475-6055-4e3c-8529-c1345df70589/resourceGroups/Azure_Demos/providers/Microsoft.Compute/virtualMachines/CentOSVM for virtualmachine /subscriptions/fed7f475-6055-4e3c-8529-c1345df70589/resourceGroups/Azure_Demos/providers/Microsoft.Compute/virtualMachines/CentOSVM was not found
>CentOSVM is a machine I created long ago.  Not sure why it’s looking for it or trying to do anything with it.

-Multiple entries with same key
>Not sure what this means.  The only time I’ve seen key mentioned in the documentation is in relation to SSH keys.

Errors:
< could not get custom images from storage account StorageService{id=/subscriptions/fed7f475-6055-4e3c-8529-c1345df70589/resourceGroups/azure_demos/providers/Microsoft.Storage/storageAccounts/azuredemosdisks998, name=azuredemosdisks998, location=eastus, tags={}, type=Microsoft.Storage/storageAccounts, storageServiceProperties=StorageServiceProperties{accountType=Premium_LRS, creationTime=Thu Nov 03 07:33:34 EDT 2016, primaryEndpoints={blob=https://azuredemosdisks998.blob.core.windows.net/}, primaryLocation=eastus, provisioningState=Succeeded, secondaryEndpoints=null, secondaryLocation=null, statusOfPrimary=Available, statusOfSecondary=null}}: request: HEAD https://azuredemosdisks998.blob.core.windows.net/system?restype=container HTTP/1.1 failed with response: HTTP/1.1 403 Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
<<   matched image(eastasia/Canonical/UbuntuServer/14.04.5-LTS) hardware(Standard_A0) location(eastasia)
>> running 1 node group(myvmlabel) location(eastasia) image(eastasia/Canonical/UbuntuServer/14.04.5-LTS) hardwareProfile(Standard_A0) options({scriptPresent=true})
>> image with id /subscriptions/fed7f475-6055-4e3c-8529-c1345df70589/resourceGroups/Azure_Demos/providers/Microsoft.Compute/virtualMachines/CentOSVM for virtualmachine /subscriptions/fed7f475-6055-4e3c-8529-c1345df70589/resourceGroups/Azure_Demos/providers/Microsoft.Compute/virtualMachines/CentOSVM was not found. This might be because the image that was used to create the virtualmachine has a new id.
error: Multiple entries with same key: Standard_A0={id=Standard_A0, providerId=Standard_A0, name=Standard_A0, location={scope=REGION, id=southeastasia, description=Southeast Asia, parent=azurecompute-arm, iso3166Codes=[SG]}, processors=[{cores=1.0, speed=2.0}], ram=768, volumes=[{type=LOCAL, size=20480.0, bootDevice=false, durable=false}, {type=LOCAL, size=1047552.0, bootDevice=false, durable=false}], supportsImage=ALWAYS_TRUE, userMetadata={maxDataDiskCount=1}} and Standard_A0={id=Standard_A0, providerId=Standard_A0, name=Standard_A0, location={scope=REGION, id=eastasia, description=East Asia, parent=azurecompute-arm, iso3166Codes=[HK]}, processors=[{cores=1.0, speed=2.0}], ram=768, volumes=[{type=LOCAL, size=20480.0, bootDevice=false, durable=false}, {type=LOCAL, size=1047552.0, bootDevice=false, durable=false}], supportsImage=ALWAYS_TRUE, userMetadata={maxDataDiskCount=1}}



From: Ignasi Barrera [mailto:nacx@apache.org]
Sent: Saturday, January 7, 2017 5:17 AM
To: user@jclouds.apache.org
Subject: Re: Example end-to-end walkthrough?

Good to see you progressed!

You're almost there. The error you are getting is because the Azure ARM provider needs some additional configuration properties.

As you might have already seen, when creating the jclouds context you can pass a set of configuration properties. This is done here [1] in the compute-basics example app, but jclouds also loads them from the system properties. You could use this to pass the additional properties when executing the jar file.

The additional properties you need to set are:

* azurecompute-arm.endpoint (because the endpoint is not fixed as it contains the subscription id).
* oauth.endpoint (because it is not fixed as it contains the tenant id).

You can follow the steps described in the Azure ARM README [2] to create an application you can use for jclouds. Once you have it, you should be able to run the examples with a command similar to:

java  -Dazurecompute-arm.endpoint="https://management.azure.com/subscriptions/<Subscription-id>" \
    -Doauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token" \
    -jar target/compute-basics-jar-with-dependencies.jar \
    azurecompute-arm <Application-Id> <Password> mygroup add


HTH!

P.S. If you want to contribute or help improve the jclouds site, you can have a look at our "How to contribute documentation" guide [3]. Also, it would be great if you could add, once you manage to run the examples with Azure, the example command to the compute-basics README [4]. That will help other future users.



[1] https://github.com/jclouds/jclouds-examples/blob/master/compute-basics/src/main/java/org/jclouds/examples/compute/basics/MainApp.java#L267-L271
[2] https://github.com/jclouds/jclouds-labs/tree/master/azurecompute-arm#setting-up-test-credentials
[3] https://cwiki.apache.org/confluence/display/JCLOUDS/How+to+Contribute+Documentation
[4] https://github.com/jclouds/jclouds-examples/blob/master/compute-basics/README.md

On 6 January 2017 at 23:42, Teo De Las Heras <te...@microsoft.com>> wrote:
I'm getting an error (below) and following up with the creators of the azurecompute-arm libraries.

Documentation feedback: I'd be happy to write up / contribute a 'jclouds for dummies' page.  I'm sure it's easy for someone who understands or works with Maven / Java projects.  Without that background, it's hard to decipher how all the pieces work together.  Or maybe some additional links to relevant Maven documentation that explains what mvn install does, what pom.xml is for, how to add dependencies (to use jclouds-labs).

Error I'm getting:
java -jar target/compute-basics-jar-with-dependencies.jar azurecompute-arm <my application id> <mypassword> mygroup add
>> initializing {id=azurecompute-arm, name=Microsoft Azure Resource Manager REST API, views=[org.jclouds.compute.ComputeServiceContext], endpointName=Resource Manager Endpoint ending in your Subscription Id, identityName=Azure Service Principal Application Id, credentialName=Optional.of(Azure Service Principal Application Password), documentation=https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx, api=interface org.jclouds.azurecompute.arm.AzureComputeApi}
Exception in thread "main" com.google.inject.CreationException: Guice creation errors:

1) No implementation for java.lang.String annotated with @com.google.inject.name.Named(value=oauth.endpoint) was bound.
  at org.jclouds.oauth.v2.config.OAuthModule.oauthEndpoint(OAuthModule.java:63)

1 error
        at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:435)
        at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:154)
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
        at com.google.inject.Guice.createInjector(Guice.java:95)
        at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:405)
        at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:328)
        at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:615)
        at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:595)
        at org.jclouds.examples.compute.basics.MainApp.initComputeService(MainApp.java:292)
        at org.jclouds.examples.compute.basics.MainApp.main(MainApp.java:141)


Teo



-----Original Message-----
From: Andrew Phillips [mailto:aphillips@qrmedia.com<ma...@qrmedia.com>]
Sent: Friday, January 6, 2017 3:25 PM
To: user@jclouds.apache.org<ma...@jclouds.apache.org>
Subject: Re: Example end-to-end walkthrough?
> I was completely confused by being directed to the github for the
> azurecompute-arm as I thought that was an example I should be
> following.


Thanks for the update! Are things working now, or is there still something that's not doing what it should?

Also, do you have any thoughts on what we could do to make the documentation clearer?

ap


Re: Example end-to-end walkthrough?

Posted by Ignasi Barrera <na...@apache.org>.
Good to see you progressed!

You're almost there. The error you are getting is because the Azure ARM
provider needs some additional configuration properties.

As you might have already seen, when creating the jclouds context you can
pass a set of configuration properties. This is done here [1] in the
compute-basics example app, but jclouds also loads them from the system
properties. You could use this to pass the additional properties when
executing the jar file.

The additional properties you need to set are:

* azurecompute-arm.endpoint (because the endpoint is not fixed as it
contains the subscription id).
* oauth.endpoint (because it is not fixed as it contains the tenant id).

You can follow the steps described in the Azure ARM README [2] to create an
application you can use for jclouds. Once you have it, you should be able
to run the examples with a command similar to:

java  -Dazurecompute-arm.endpoint="
https://management.azure.com/subscriptions/<Subscription-id>" \
    -Doauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token"
\
    -jar target/compute-basics-jar-with-dependencies.jar \
    azurecompute-arm <Application-Id> <Password> mygroup add


HTH!

P.S. If you want to contribute or help improve the jclouds site, you can
have a look at our "How to contribute documentation" guide [3]. Also, it
would be great if you could add, once you manage to run the examples with
Azure, the example command to the compute-basics README [4]. That will help
other future users.



[1]
https://github.com/jclouds/jclouds-examples/blob/master/compute-basics/src/main/java/org/jclouds/examples/compute/basics/MainApp.java#L267-L271
[2]
https://github.com/jclouds/jclouds-labs/tree/master/azurecompute-arm#setting-up-test-credentials
[3]
https://cwiki.apache.org/confluence/display/JCLOUDS/How+to+Contribute+Documentation
[4]
https://github.com/jclouds/jclouds-examples/blob/master/compute-basics/README.md

On 6 January 2017 at 23:42, Teo De Las Heras <te...@microsoft.com> wrote:

> I'm getting an error (below) and following up with the creators of the
> azurecompute-arm libraries.
>
> Documentation feedback: I'd be happy to write up / contribute a 'jclouds
> for dummies' page.  I'm sure it's easy for someone who understands or works
> with Maven / Java projects.  Without that background, it's hard to decipher
> how all the pieces work together.  Or maybe some additional links to
> relevant Maven documentation that explains what mvn install does, what
> pom.xml is for, how to add dependencies (to use jclouds-labs).
>
> Error I'm getting:
> java -jar target/compute-basics-jar-with-dependencies.jar
> azurecompute-arm <my application id> <mypassword> mygroup add
> >> initializing {id=azurecompute-arm, name=Microsoft Azure Resource
> Manager REST API, views=[org.jclouds.compute.ComputeServiceContext],
> endpointName=Resource Manager Endpoint ending in your Subscription Id,
> identityName=Azure Service Principal Application Id,
> credentialName=Optional.of(Azure Service Principal Application Password),
> documentation=https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx,
> api=interface org.jclouds.azurecompute.arm.AzureComputeApi}
> Exception in thread "main" com.google.inject.CreationException: Guice
> creation errors:
>
> 1) No implementation for java.lang.String annotated with
> @com.google.inject.name.Named(value=oauth.endpoint) was bound.
>   at org.jclouds.oauth.v2.config.OAuthModule.oauthEndpoint(
> OAuthModule.java:63)
>
> 1 error
>         at com.google.inject.internal.Errors.
> throwCreationExceptionIfErrorsExist(Errors.java:435)
>         at com.google.inject.internal.InternalInjectorCreator.
> initializeStatically(InternalInjectorCreator.java:154)
>         at com.google.inject.internal.InternalInjectorCreator.build(
> InternalInjectorCreator.java:106)
>         at com.google.inject.Guice.createInjector(Guice.java:95)
>         at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.
> java:405)
>         at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.
> java:328)
>         at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:615)
>         at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:595)
>         at org.jclouds.examples.compute.basics.MainApp.
> initComputeService(MainApp.java:292)
>         at org.jclouds.examples.compute.basics.MainApp.main(MainApp.
> java:141)
>
>
> Teo
>
>
>
> -----Original Message-----
> From: Andrew Phillips [mailto:aphillips@qrmedia.com]
> Sent: Friday, January 6, 2017 3:25 PM
> To: user@jclouds.apache.org
> Subject: Re: Example end-to-end walkthrough?
>
> > I was completely confused by being directed to the github for the
> > azurecompute-arm as I thought that was an example I should be
> > following.
>
>
> Thanks for the update! Are things working now, or is there still something
> that's not doing what it should?
>
> Also, do you have any thoughts on what we could do to make the
> documentation clearer?
>
> ap
>

RE: Example end-to-end walkthrough?

Posted by Teo De Las Heras <te...@microsoft.com>.
I'm getting an error (below) and following up with the creators of the azurecompute-arm libraries.

Documentation feedback: I'd be happy to write up / contribute a 'jclouds for dummies' page.  I'm sure it's easy for someone who understands or works with Maven / Java projects.  Without that background, it's hard to decipher how all the pieces work together.  Or maybe some additional links to relevant Maven documentation that explains what mvn install does, what pom.xml is for, how to add dependencies (to use jclouds-labs).

Error I'm getting:
java -jar target/compute-basics-jar-with-dependencies.jar azurecompute-arm <my application id> <mypassword> mygroup add
>> initializing {id=azurecompute-arm, name=Microsoft Azure Resource Manager REST API, views=[org.jclouds.compute.ComputeServiceContext], endpointName=Resource Manager Endpoint ending in your Subscription Id, identityName=Azure Service Principal Application Id, credentialName=Optional.of(Azure Service Principal Application Password), documentation=https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx, api=interface org.jclouds.azurecompute.arm.AzureComputeApi}
Exception in thread "main" com.google.inject.CreationException: Guice creation errors:

1) No implementation for java.lang.String annotated with @com.google.inject.name.Named(value=oauth.endpoint) was bound.
  at org.jclouds.oauth.v2.config.OAuthModule.oauthEndpoint(OAuthModule.java:63)

1 error
        at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:435)
        at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:154)
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
        at com.google.inject.Guice.createInjector(Guice.java:95)
        at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:405)
        at org.jclouds.ContextBuilder.buildInjector(ContextBuilder.java:328)
        at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:615)
        at org.jclouds.ContextBuilder.buildView(ContextBuilder.java:595)
        at org.jclouds.examples.compute.basics.MainApp.initComputeService(MainApp.java:292)
        at org.jclouds.examples.compute.basics.MainApp.main(MainApp.java:141)


Teo



-----Original Message-----
From: Andrew Phillips [mailto:aphillips@qrmedia.com] 
Sent: Friday, January 6, 2017 3:25 PM
To: user@jclouds.apache.org
Subject: Re: Example end-to-end walkthrough?

> I was completely confused by being directed to the github for the 
> azurecompute-arm as I thought that was an example I should be 
> following.


Thanks for the update! Are things working now, or is there still something that's not doing what it should?

Also, do you have any thoughts on what we could do to make the documentation clearer?

ap

Re: Example end-to-end walkthrough?

Posted by Andrew Phillips <ap...@qrmedia.com>.
> I was completely confused by being directed to the github for the
> azurecompute-arm as I thought that was an example I should be
> following.


Thanks for the update! Are things working now, or is there still 
something that's not doing what it should?

Also, do you have any thoughts on what we could do to make the 
documentation clearer?

ap

RE: Example end-to-end walkthrough?

Posted by Teo De Las Heras <te...@microsoft.com>.
OK, I think I'm finally understanding Maven and what was done to get azurecompute-arm to work.

So, to add additional dependencies, you look here:
http://search.maven.org/#artifactdetails%7Corg.apache.jclouds.labs%7Cazurecompute-arm%7C2.0.0%7Cbundle
And, to use azurecompute-arm, I add the following:
<dependency>
    <groupId>org.apache.jclouds.labs</groupId>
    <artifactId>azurecompute-arm</artifactId>
    <version>2.0.0</version>
</dependency>

I was completely confused by being directed to the github for the azurecompute-arm as I thought that was an example I should be following.

Teo

-----Original Message-----
From: Teo De Las Heras 
Sent: Thursday, January 5, 2017 8:21 PM
To: user@jclouds.apache.org
Subject: RE: Example end-to-end walkthrough?

Thanks for all the help.  I'm trying to learn how to run a basic example that I can learn from and build on, but my lack of knowledge of Maven is a pitfall.  All the examples use Maven differently which makes it hard to learn from the examples.

The other challenge I'm having is that the compute-basics example is very different from the azurecompute-arm example.  There are 102 java files which appear to be helper libraries.  I'm guessing I need those helper libraries, even for the compute-basics example?

Ignasi said "add the azure dependency to its pom.xml".  Not knowing Maven or what's required to run computer-basics vs azurecompute-arm, I'm not sure what / how to do that.   The  dependencies in azurecompute-arm don't refer to anything Azure specific.

I tried running the compute-basics example and specifying the provider as azurecompute-arm but got the error that azurecompute-arm isn't an available provider (makes sense because ARM is listed in the documentation as only being available in labs).  From what I saw in the azurecompute-arm examples, the pom.xml there uses different groupID and artifactID (and points to ....-labs). 

So, given the above, I tried copying the parent, artifactID, and properties from the azurecompute-arm pom.xml to the compute-basics pom.xml but mvn install fails: Failed to execute goal org.basepom.maven:duplicate-finder-maven-plugin:1.1.1:check (default) on project azurecompute-arm: Found duplicate classes/resources! -> [Help 1]





-----Original Message-----
From: Andrew Phillips [mailto:andrewp@apache.org]
Sent: Thursday, January 5, 2017 9:52 AM
To: user@jclouds.apache.org
Subject: Re: Example end-to-end walkthrough?

> But in the end, like in any Java project, the only thing you need to 
> use jclouds is your project is to have the jclouds .jar files in your 
> classpath.

Just for the avoidance of doubt: you will need the jclouds JAR files and the JARs for any dependencies needed by the particular jclouds JARs you are using.

Retrieving these dependencies is what the Maven dependency plugin's "copy-dependencies" goal is about:

https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html

To Ignasi's earlier point: if you *do* happen to be looking for a standalone executable that could be used to interact with cloud APIs, the jclouds CLI is one possible option you may want to look at:

https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html

Regards

ap

RE: Example end-to-end walkthrough?

Posted by Teo De Las Heras <te...@microsoft.com>.
Thanks for all the help.  I'm trying to learn how to run a basic example that I can learn from and build on, but my lack of knowledge of Maven is a pitfall.  All the examples use Maven differently which makes it hard to learn from the examples.

The other challenge I'm having is that the compute-basics example is very different from the azurecompute-arm example.  There are 102 java files which appear to be helper libraries.  I'm guessing I need those helper libraries, even for the compute-basics example?

Ignasi said "add the azure dependency to its pom.xml".  Not knowing Maven or what's required to run computer-basics vs azurecompute-arm, I'm not sure what / how to do that.   The  dependencies in azurecompute-arm don't refer to anything Azure specific.

I tried running the compute-basics example and specifying the provider as azurecompute-arm but got the error that azurecompute-arm isn't an available provider (makes sense because ARM is listed in the documentation as only being available in labs).  From what I saw in the azurecompute-arm examples, the pom.xml there uses different groupID and artifactID (and points to ....-labs). 

So, given the above, I tried copying the parent, artifactID, and properties from the azurecompute-arm pom.xml to the compute-basics pom.xml but mvn install fails: Failed to execute goal org.basepom.maven:duplicate-finder-maven-plugin:1.1.1:check (default) on project azurecompute-arm: Found duplicate classes/resources! -> [Help 1]





-----Original Message-----
From: Andrew Phillips [mailto:andrewp@apache.org] 
Sent: Thursday, January 5, 2017 9:52 AM
To: user@jclouds.apache.org
Subject: Re: Example end-to-end walkthrough?

> But in the end, like in any Java project, the only thing you need to 
> use jclouds is your project is to have the jclouds .jar files in your 
> classpath.

Just for the avoidance of doubt: you will need the jclouds JAR files and the JARs for any dependencies needed by the particular jclouds JARs you are using.

Retrieving these dependencies is what the Maven dependency plugin's "copy-dependencies" goal is about:

https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html

To Ignasi's earlier point: if you *do* happen to be looking for a standalone executable that could be used to interact with cloud APIs, the jclouds CLI is one possible option you may want to look at:

https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html

Regards

ap

Re: Example end-to-end walkthrough?

Posted by Andrew Phillips <an...@apache.org>.
> But in the end, like in any Java project, the only thing you
> need to use jclouds is your project is to have the jclouds .jar
> files in your classpath.

Just for the avoidance of doubt: you will need the jclouds JAR files and 
the JARs for any dependencies needed by the particular jclouds JARs you 
are using.

Retrieving these dependencies is what the Maven dependency plugin's 
"copy-dependencies" goal is about:

https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html

To Ignasi's earlier point: if you *do* happen to be looking for a 
standalone executable that could be used to interact with cloud APIs, 
the jclouds CLI is one possible option you may want to look at:

https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html

Regards

ap

Re: Example end-to-end walkthrough?

Posted by Ignasi Barrera <na...@apache.org>.
Hi,

jclouds is just a collection of APIs. It is not an executable or a
precompiled tool you can use out of the box to manage the different
cloud providers. It is a set of APIs you can use to write code that
can be used to manage any supported cloud.

The references to Maven or the reference to the jclouds-examples are
just the most common ways of configuring a Java project to use
jclouds. But in the end, like in any Java project, the only thing you
need to use jclouds is your project is to have the jclouds .jar files
in your classpath.

This said, the easiest way of starting a project that will use jclouds
is to use Maven, and configure the jclouds dependencies in the
pom.xml, just like is done in the jclouds-examples compute-basics
project. (The other pom files in the "main" jclouds repo are the ones
used to build jclouds itself; not examples on how to use the jclouds
jars).

To use Azure ARM you could easily copy the compute-basics project and
add the azure dependency to its pom.xml. That pom.xml is already
prepared to create an executable jar file, so it should be ready to
go. Just add the dependency and modify the code as needed for your
needs.



On 4 January 2017 at 21:36, Teo De Las Heras <te...@microsoft.com> wrote:
> Thanks for the replies.  Apologies for the n00b questions that follow…from
> what I've read, is my understanding below correct:
>
> Pom.xml is used by mvm to download the necessary jclouds binaries?
>
> http://jclouds.apache.org/start/install/
>
> Mvn dependency:copy-dependencies
>
> Maybe it’s just is an mvn / java ‘preference’ (which I don’t have a lot of
> experience with) but there doesn't seem to be consistency in the examples
> for how this should 'run'.
>
> The compute basics example:
> https://github.com/jclouds/jclouds-examples/tree/master/compute-basics
> Says to run mvn install and then java -jar … and never mentions running mvn
> dependency:copy-dependencies
> The Azure ARM example:
> https://github.com/jclouds/jclouds-labs/tree/master/azurecompute-arm
> Says to run mvn -DTest … DTest isn’t in the Maven documentation:
>
> https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
> Why would mvn install be needed in the compute basics but not the Azure ARM
> example?
>
> Once Pom.xml is ‘processed’ by mvn, I can build a .jar file that uses the
> jclouds API’s?
>
> http://jclouds.apache.org/start/compute/
>
> Java -jar …
>
> Again, maybe this is just an mvn / Java preference but why doesn’t the Azure
> ARM example show this?  Instead it just shows mvn
>
>
>
> Thank you,
>
>
>
> Teo De Las Heras
>
>
>
> -----Original Message-----
> From: Ignasi Barrera [mailto:nacx@apache.org]
> Sent: Thursday, December 29, 2016 4:58 PM
> To: user@jclouds.apache.org
> Cc: Teo De Las Heras <te...@microsoft.com>
> Subject: Re: Example end-to-end walkthrough?
>
>
>
> Trying to understand the compute basics examples is one of the better ways
> to get started with jclouds.
>
>
>
> There are two different Azure providers in jclouds:
>
>
>
> * The "azurecompute" one uses the old Azure API.
>
> * The "azurecompute-arm" uses the new ARM API.
>
>
>
> You'll need to add the "org.apache.jclouds.labs/azurecompute" or
> "org.apache.jclouds.labs/azurecompute-arm" dependencies to your project in
> order to use them.
>
>
>
> In the README for the azurecompute-arm provider you will find the
> instructions to create an Application in your subscription for
>
> jclouds:
>
> https://github.com/jclouds/jclouds-labs/tree/master/azurecompute-arm
>
>
>
> You might also find the following talks useful:
>
> https://speakerdeck.com/nacx/rule-the-cloud-with-apache-jclouds
>
> http://feathercast.apache.org/apachecon-na-2016-rule-the-cloud-with-apache-jclouds-ignasi-barrera/
>
> (audio recording for the talk)
>
> https://github.com/nacx/acna2016-demo (simple source code for the demo)
>
>
>
> https://speakerdeck.com/nacx/introduction-to-apache-jclouds-apachecon-eu-2014
>
>
>
>
>
> HTH!
>
>
>
> I.
>
>
>
> On 23 December 2016 at 20:20, Andrew Phillips <ap...@qrmedia.com> wrote:
>
>> Hi Teo
>
>>
>
>> The jclouds-examples repo [1] may help - I don't think it has an
>
>> Azure-specific example at present, but the general "compute-basics"
>
>> app should hopefully give a better idea of how the end-to-end flow
>
>> might look
>
>> like:
>
>>
>
>> https://github.com/jclouds/jclouds-examples/blob/master/compute-basics
>
>> /src/main/java/org/jclouds/examples/compute/basics/MainApp.java
>
>>
>
>> It uses the jclouds' compute abstraction, but should also work with
>
>> the Azure providers.
>
>>
>
>> Of course, suggestions and/or PRs for ways we can improve the initial
>
>> "how does this all fit together?" documentation are also much
>
>> appreciated - definitely things we can do there.
>
>>
>
>> Regards
>
>>
>
>> ap
>
>>
>
>> [1] https://github.com/jclouds/jclouds-examples/