merge in changes from upstream

This commit is contained in:
Robert Outlaw 2017-05-05 12:25:22 -07:00
Родитель 0290d9a84c c995760684
Коммит 3dce77294f
7 изменённых файлов: 62 добавлений и 60 удалений

Просмотреть файл

@ -48,21 +48,20 @@ In addition to using Java libraries to create and manage resources within Azure,
For example, to print out the contents of all blobs in an Azure storage container:
```java
// get the container from the blob client
CloudBlobContainer container = blobClient.getContainerReference("blobcontainer");
// get the container from the blob client
CloudBlobContainer container = blobClient.getContainerReference("blobcontainer");
// For each item in the container
for (ListBlobItem blobItem : container.listBlobs()) {
// For each item in the container
for (ListBlobItem blobItem : container.listBlobs()) {
// If the item is a blob, not a virtual directory
if (blobItem instanceof CloudBlockBlob) {
// Download the text
CloudBlockBlob retrievedBlob = (CloudBlockBlob) blobItem;
System.out.println(retrievedBlob.downloadText());
}
}
}
```
## Sample code and reference
The following samples cover common automation tasks with the Azure management libraries for Java and have code ready to use in your own apps:

Просмотреть файл

@ -19,7 +19,7 @@ ms.assetid: 10f457e3-578b-4655-8cd1-51339226ee7d
## Connect to services with connection strings
Most Azure service libraries use a connection string or keys to connect to the service from your app. For example, SQL Database uses a JDBC connection string:
Most Azure service libraries use a connection string or secure key to authenticate to the service. For example, SQL Database uses a JDBC connection string:
```java
String url = "jdbc:sqlserver://myazuredb.database.windows.net:1433;" +
@ -39,17 +39,17 @@ final String storageConnection = "DefaultEndpointsProtocol=https;"
+ ";EndpointSuffix=core.windows.net";
```
Service connection strings are used to authenticate to other Azure services like [DocumentDB](https://docs.microsoft.com/azure/documentdb/documentdb-java-application#a-iduseserviceastep-4-using-the-documentdb-service-in-a-java-application), [Redis Cache](https://docs.microsoft.com/azure/redis-cache/cache-java-get-started), and [Service Bus](https://docs.microsoft.com/azure/service-bus-messaging/service-bus-java-how-to-use-queues) and you can get those strings using the Azure portal or the CLI. You can also use the Azure management libraries for Java to query resources to build connection strings in your code.
Service connection strings are used to authenticate to other Azure services like [DocumentDB](https://docs.microsoft.com/azure/documentdb/documentdb-java-application#a-iduseserviceastep-4-using-the-documentdb-service-in-a-java-application), [Redis Cache](https://docs.microsoft.com/azure/redis-cache/cache-java-get-started), and [Service Bus](https://docs.microsoft.com/azure/service-bus-messaging/service-bus-java-how-to-use-queues). You can get the connection strings using the Azure portal or the CLI. You can also use the Azure management libraries for Java to query resources to build connection strings in your code.
This snippet uses the management libraries to create a storage account connection string:
```java
// create a new storage account
StorageAccount stor2 = azure.storageAccounts().getByResourceGroup("myResourceGroup","myStorageAccount");
// create a new storage account
StorageAccount stor2 = azure.storageAccounts().getByResourceGroup("myResourceGroup","myStorageAccount");
// create a storage container to hold the file
List<StorageAccountKey> keys = storage.getKeys();
final String storageConnection = "DefaultEndpointsProtocol=https;"
// create a storage container to hold the file
List<StorageAccountKey> keys = storage.getKeys();
final String storageConnection = "DefaultEndpointsProtocol=https;"
+ "AccountName=" + storage.name()
+ ";AccountKey=" + keys.get(0).value()
+ ";EndpointSuffix=core.windows.net";
@ -67,14 +67,17 @@ Two options are available to authenticate your application with Azure when using
Create an instance of `ApplicationTokenCredentials` to supply the service principal credentials to the top-level `Azure` object from inside your code.
```
```java
import com.microsoft.azure.credentials.ApplicationTokenCredentials;
import com.microsoft.azure.AzureEnvironment;
...
// ...
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(client,
tenant,
key,
AzureEnvironment.AZURE);
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(client, tenant,
key, AzureEnvironment.AZURE);
Azure azure = Azure
.configure()
.withLogLevel(LogLevel.NONE)
@ -82,7 +85,7 @@ Azure azure = Azure
.withDefaultSubscription();
```
The `client`, `tenant` and `key` are the same service principal values used with file-based authentication. The `AzureEnvironment.AZURE` value creates credentials against the Azure public cloud. Change this to a different `AzureEnvironment` enum value if you need to access another cloud (for example, `AzureEnvironment.AZURE_GERMANY`). Read the service principal values from environment variables or a secret management store like [Key Vault](/azure/key-vault/key-vault-whatis.md). Avoid setting these values as cleartext strings in your code to prevent a leak of the credentials through your version control history.
The `client`, `tenant` and `key` are the same service principal values used with [file-based authentication](#mgmt-file). The `AzureEnvironment.AZURE` value creates credentials against the Azure public cloud. Change this to a different `AzureEnvironment` enum value if you need to access another cloud (for example, `AzureEnvironment.AZURE_GERMANY`). Read the service principal values from environment variables or a secret management store like [Key Vault](/azure/key-vault/key-vault-whatis.md). Avoid setting these values as cleartext strings in your code to prevent a leak of the credentials through your version control history.
<a name="mgmt-file"></a>

Просмотреть файл

@ -65,8 +65,8 @@ for (VirtualMachine vm : vms) {
The management libraries follows a convention for returned collections from queries:
- Lists: Unordered data that is easy to search and interate over.
- Maps: Maps are key/value pairs with unique keys, but not necessarily unique values. An example of a Map would be app settings for a App Service webapp.
- Lists: Unordered data that is easy to search and iterate over.
- Maps: Maps are key/value pairs with unique keys, but not necessarily unique values. An example of a Map would be app settings for an App Service Web App.
- Sets: Sets have unique keys and values. An example of a Set would be networks attached to a virtual machine, which would have both an unique identifier (the key) and a unique network configuration (the value).
## Actionable verbs
@ -84,7 +84,7 @@ Methods with verbs in their names take immediate action in Azure. These methods
>[!NOTE]
> `define()` and `update()` are verbs but do not block unless followed by a `create()` or `apply()`.
Asynchronous versions of these methods exist with a `Async` suffix use [Reactive extensions](https://github.com/ReactiveX/RxJava).
Asynchronous versions of these methods exist with the `Async` suffix using [Reactive extensions](https://github.com/ReactiveX/RxJava).
Some objects have methods with that change the state of the resource in Azure. For example, `restart()` on a `VirtualMachine`:
@ -131,7 +131,7 @@ PublicIPAddress pip = (PublicIPAddress) virtualMachine.createdRelatedResource(pu
## Exception handling
The management libraries currently defines Exception classes that extend `com.microsoft.rest.RestException`. Catch exceptions generated by management libraries, with a `catch (RestException exception)` block after the relevant `try` statement.
The management libraries define Exception classes that extend `com.microsoft.rest.RestException`. Catch exceptions generated by management libraries with a `catch (RestException exception)` block after the relevant `try` statement.
## Logs and trace

Просмотреть файл

@ -41,7 +41,7 @@ Other Java build tools like Gradle are supported but the install steps are not p
## Azure service libraries
Integrate Azure services to add functionality to your apps using these libraries. Learn more about building apps with Azure services at [Java developer center](https://azure.microsoft.com/develop/java).
Integrate Azure services to add functionality to your apps using these libraries. Learn more about building apps with Azure services at the [Java developer center](https://azure.microsoft.com/develop/java).
<a name="azure-storage"></a>
@ -161,7 +161,7 @@ Safely access keys and secrets from your applications.
### [Event Hub](https://docs.microsoft.com/azure/event-hubs/event-hubs-what-is-event-hubs)
High throughput event and telemetry handling for your instrumentation or IoT scenarios.
High-throughput event and telemetry handling for your instrumentation or IoT scenarios.
```XML
<dependency>

Просмотреть файл

@ -21,9 +21,9 @@ ms.assetid: e4537f38-a60d-4218-a9ba-3cba7af61b8b
|---|---|
| [Create and manage SQL databases][1] | Create SQL databases, set performance levels, and configure firewalls. |
| **Scale databases** ||
| [Manage SQL databases across multiple regions][2] | Create a master SQL databases and read-only databases from the master in multiple regions. Connect VMs to their nearest SQL database instance with a virtual network and firewall rules. |
| [Manage SQL databases across multiple regions][2] | Create a master SQL database and read-only databases from the master in multiple regions. Connect VMs to their nearest SQL database instance with a virtual network and firewall rules. |
| **Elastic Pools** ||
| [Manage SQL Databases in elastic pools][3] | Create, delete, and move SQL databases in and out of elastic pools. |
| [Manage SQL databases in elastic pools][3] | Create, delete, and move SQL databases in and out of elastic pools. |
[1]: https://azure.microsoft.com/resources/samples/sql-database-java-manage-db/
[2]: https://azure.microsoft.com/resources/samples/sql-database-java-manage-sql-databases-across-regions/

Просмотреть файл

@ -22,11 +22,11 @@ The following table links to Java source you can use to create and configure Azu
|---|---|
| [Manage virtual machines][1] | Create, modify, start, stop, and delete virtual machines. |
| [Create a virtual machine from a custom image][2] | Create a custom virtual machine image and use it to create new virtual machines. |
| [Create a virtual machine using specialized VHD from a snapshot][3] | Create snapshot from the virtual machine's OS and data disks, create managed disks from the snapshots, then create a virtual machine by attaching the managed disks. |
| [Create a virtual machine using specialized VHD from a snapshot][3] | Create snapshot from the virtual machine's OS and data disks, create managed disks from the snapshots, and then create a virtual machine by attaching the managed disks. |
| [Create virtual machines in parallel in the same network][4] | Create virtual machines in the same region on the same virtual network with two subnets in parallel. |
| [Create virtual machines across regions in parallel][5] | Create and load balance a set of virtual machines across multiple Azure regions. |
| [Create virtual machines across regions in parallel][5] | Create and load-balance a set of virtual machines across multiple Azure regions. |
| **Network virtual machines** ||
| [Manage virtual networks][6] | Set up a virtual network with two subnets and restrict Internet access to the subnets. |
| [Manage virtual networks][6] | Set up a virtual network with two subnets and restrict Internet access to them. |
| **Create scale sets** ||
| [Create a virtual machine scale set with a load balancer][7] | Create a VM scale set, set up a load balancer, and get SSH connection strings to the scale set VMs. |

Просмотреть файл

@ -18,15 +18,15 @@ ms.assetid: 43633e5c-9fb1-4807-ba63-e24c126754e2
| **Create an app** ||
|---|---|
| [Create a web app and deploy from FTP or GitHub][1] | Deploy web apps through local Git, FTP, and continuous integration from GitHub. |
| [Create a web app and manage deployment slots][2] | Create a web app and deploy to staging slots, then swap between slots. |
| [Create a web app and deploy from FTP or GitHub][1] | Deploy web apps from local Git, FTP, and continuous integration from GitHub. |
| [Create a web app and manage deployment slots][2] | Create a web app and deploy to staging slots, and then swap deployments between slots. |
| **Configure app** ||
| [Create a web app and configure a custom domain][3] | Create a web app with a custom domain and self-signed SSL certificate. |
| **Scale apps** ||
| [Scale a web app with high availability across multiple regions][4] | Scale a web app in three different geographical regions and make them available through a single endpoint using Azure Traffic Manager. |
| **Connect app to resources** ||
| [Connect a web app to a storage account][5] | Create an Azure storage account and add the storage account connection string to the app settings. |
| [Connect a web app to a SQL database][6] | Create a web app and SQL database, then add the SQL database connection string to the app settings. |
| [Connect a web app to a SQL database][6] | Create a web app and SQL database, and then add the SQL database connection string to the app settings. |
[1]: java-sdk-configure-webapp-sources.md
[2]: https://azure.microsoft.com/resources/samples/app-service-java-manage-staging-and-production-slots-for-web-apps/