Skip to content

Commit 03fdd16

Browse files
authored
Merge pull request #100101 from dagiro/freshness162
freshness162
2 parents 99adc4b + 312c98d commit 03fdd16

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

articles/hdinsight/hdinsight-go-sdk-overview.md

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
22
title: Azure HDInsight SDK for Go
33
description: Reference material for using Azure HDInsight SDK for Go and Apache Hadoop clusters
4-
author: tylerfox
5-
4+
author: hrasheed-msft
5+
ms.author: hrasheed
6+
ms.reviewer: jasonh
67
ms.service: hdinsight
78
ms.topic: conceptual
8-
ms.date: 05/8/2019
9-
ms.author: tyfox
10-
ms.reviewer: jasonh
119
ms.custom: seodec18
10+
ms.date: 01/03/2020
1211
---
1312

1413
# HDInsight SDK for Go (Preview)
@@ -19,9 +18,11 @@ The HDInsight SDK for Go provides classes and functions that allow you to manage
1918
> [!NOTE]
2019
>GoDoc reference material for this SDK is also [available here](https://godoc.org/github.com/Azure/azure-sdk-for-go/services/preview/hdinsight/mgmt/2018-06-01-preview/hdinsight).
2120
21+
If you don’t have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
22+
2223
## Prerequisites
2324

24-
* An Azure account. If you don't have one, [get a free trial](https://azure.microsoft.com/free/).
25+
* A [`go get` tool](https://github.com/golang/go/wiki/GoGetTools).
2526
* [Go](https://golang.org/dl/).
2627

2728
## SDK installation
@@ -30,14 +31,14 @@ From your GOPATH location, run `go get github.com/Azure/azure-sdk-for-go/tree/ma
3031

3132
## Authentication
3233

33-
The SDK first needs to be authenticated with your Azure subscription. Follow the example below to create a service principal and use it to authenticate. After this is done, you will have an instance of a `ClustersClient`, which contains many functions (outlined in below sections) that can be used to perform management operations.
34+
The SDK first needs to be authenticated with your Azure subscription. Follow the example below to create a service principal and use it to authenticate. After this is done, you'll have an instance of a `ClustersClient`, which contains many functions (outlined in below sections) that can be used to perform management operations.
3435

3536
> [!NOTE]
3637
> There are other ways to authenticate besides the below example that could potentially be better suited for your needs. All functions are outlined here: [Authentication functions in the Azure SDK for Go](https://docs.microsoft.com/azure/go/azure-sdk-go-authorization)
3738
3839
### Authentication example using a service principal
3940

40-
First, login to [Azure Cloud Shell](https://shell.azure.com/bash). Verify you are currently using the subscription in which you want the service principal created.
41+
First, login to [Azure Cloud Shell](https://shell.azure.com/bash). Verify you're currently using the subscription in which you want the service principal created.
4142

4243
```azurecli-interactive
4344
az account show
@@ -94,6 +95,7 @@ The service principal information is displayed as JSON.
9495
"managementEndpointUrl": "https://management.core.windows.net/"
9596
}
9697
```
98+
9799
Copy the below snippet and fill in `TENANT_ID`, `CLIENT_ID`, `CLIENT_SECRET`, and `SUBSCRIPTION_ID` with the strings from the JSON that was returned after running the command to create the service principal.
98100

99101
```golang
@@ -138,29 +140,35 @@ A new cluster can be created by calling `client.Create()`.
138140
139141
#### Example
140142
141-
This example demonstrates how to create an [Apache Spark](https://spark.apache.org/) cluster with 2 head nodes and 1 worker node.
143+
This example demonstrates how to create an [Apache Spark](https://spark.apache.org/) cluster with two head nodes and one worker node.
142144
143145
> [!NOTE]
144146
> You first need to create a Resource Group and Storage Account, as explained below. If you have already created these, you can skip these steps.
145147
146148
##### Creating a resource group
147149
148150
You can create a resource group using the [Azure Cloud Shell](https://shell.azure.com/bash) by running
151+
149152
```azurecli-interactive
150153
az group create -l <Region Name (i.e. eastus)> --n <Resource Group Name>
151154
```
155+
152156
##### Creating a storage account
153157
154158
You can create a storage account using the [Azure Cloud Shell](https://shell.azure.com/bash) by running:
159+
155160
```azurecli-interactive
156161
az storage account create -n <Storage Account Name> -g <Existing Resource Group Name> -l <Region Name (i.e. eastus)> --sku <SKU i.e. Standard_LRS>
157162
```
158-
Now run the following command to get the key for your storage account (you will need this to create a cluster):
163+
164+
Now run the following command to get the key for your storage account (you'll need this to create a cluster):
165+
159166
```azurecli-interactive
160167
az storage account keys list -n <Storage Account Name>
161168
```
169+
162170
---
163-
The below Go snippet creates a Spark cluster with 2 head nodes and 1 worker node. Fill in the blank variables as explained in the comments and feel free to change other parameters to suit your specific needs.
171+
The below Go snippet creates a Spark cluster with two head nodes and one worker node. Fill in the blank variables as explained in the comments and feel free to change other parameters to suit your specific needs.
164172
165173
```golang
166174
// The name for the cluster you are creating
@@ -251,7 +259,7 @@ client.Get(context.Background(), "<Resource Group Name>", "<Cluster Name>")
251259
252260
#### Example
253261
254-
You can use `get` to confirm that you have successfully created your cluster.
262+
You can use `get` to confirm that you've successfully created your cluster.
255263
256264
```golang
257265
cluster, err := client.Get(context.Background(), resourceGroupName, clusterName)
@@ -272,10 +280,13 @@ The output should look like:
272280
### List clusters
273281
274282
#### List clusters under the subscription
283+
275284
```golang
276285
client.List()
277286
```
287+
278288
#### List clusters by resource group
289+
279290
```golang
280291
client.ListByResourceGroup("<Resource Group Name>")
281292
```
@@ -284,6 +295,7 @@ client.ListByResourceGroup("<Resource Group Name>")
284295
> Both `List()` and `ListByResourceGroup()` return a `ClusterListResultPage` struct. To get the next page, you can call `Next()`. This can be repeated until `ClusterListResultPage.NotDone()` returns `false`, as shown in the example below.
285296
286297
#### Example
298+
287299
The following example prints the properties of all clusters for the current subscription:
288300
289301
```golang
@@ -317,6 +329,7 @@ You can update the tags of a given cluster like so:
317329
```golang
318330
client.Update(context.Background(), "<Resource Group Name>", "<Cluster Name>", hdi.ClusterPatchParameters{<map[string]*string} of Tags>)
319331
```
332+
320333
#### Example
321334
322335
```golang
@@ -335,7 +348,7 @@ client.Resize(context.Background(), "<Resource Group Name>", "<Cluster Name>", h
335348
336349
The HDInsight Management SDK can also be used to manage monitoring on your clusters via the Operations Management Suite (OMS).
337350
338-
Similarly to how you created `ClusterClient` to use for management operations, you need to create an `ExtensionClient` to use for monitoring operations. Once you have completed the Authentication section above, you can create an `ExtensionClient` like so:
351+
Similarly to how you created `ClusterClient` to use for management operations, you need to create an `ExtensionClient` to use for monitoring operations. Once you've completed the Authentication section above, you can create an `ExtensionClient` like so:
339352
340353
```golang
341354
extClient := hdi.NewExtensionsClient(SUBSCRIPTION_ID)
@@ -388,7 +401,7 @@ var scriptAction1 = hdi.RuntimeScriptAction{Name: to.StringPtr("<Script Name>"),
388401
client.ExecuteScriptActions(context.Background(), "<Resource Group Name>", "<Cluster Name>", hdi.ExecuteScriptActionParameters{PersistOnSuccess: to.BoolPtr(true), ScriptActions: &[]hdi.RuntimeScriptAction{scriptAction1}}) //add more RuntimeScriptActions to the list to execute multiple scripts
389402
```
390403
391-
For the 'Delete Script Action' and 'List Persisted Script Actions' operations, you need to create a `ScriptActionsClient`, similarly to how you created `ClusterClient` to use for management operations. Once you have completed the Authentication section above, you can create a `ScriptActionsClient` like so:
404+
For the 'Delete Script Action' and 'List Persisted Script Actions' operations, you need to create a `ScriptActionsClient`, similarly to how you created `ClusterClient` to use for management operations. Once you've completed the Authentication section above, you can create a `ScriptActionsClient` like so:
392405
393406
```golang
394407
scriptActionsClient := hdi.NewScriptActionsClient(SUBSCRIPTION_ID)
@@ -436,7 +449,7 @@ for (page.NotDone()) {
436449
437450
### List all scripts' execution history
438451
439-
For this operation, you need to create a `ScriptExecutionHistoryClient`, similarly to how you created `ClusterClient` to use for management operations. Once you have completed the Authentication section above, you can create a `ScriptActionsClient` like so:
452+
For this operation, you need to create a `ScriptExecutionHistoryClient`, similarly to how you created `ClusterClient` to use for management operations. Once you've completed the Authentication section above, you can create a `ScriptActionsClient` like so:
440453
441454
```golang
442455
scriptExecutionHistoryClient := hdi.NewScriptExecutionHistoryClient(SUBSCRIPTION_ID)
@@ -474,4 +487,4 @@ for (page.NotDone()) {
474487
475488
## Next steps
476489
477-
* Explore the [GoDoc reference material](https://godoc.org/github.com/Azure/azure-sdk-for-go/services/preview/hdinsight/mgmt/2018-06-01-preview/hdinsight). The GoDocs provide reference documentation for all functions in the SDK.
490+
Explore the [GoDoc reference material](https://godoc.org/github.com/Azure/azure-sdk-for-go/services/preview/hdinsight/mgmt/2018-06-01-preview/hdinsight). The GoDocs provide reference documentation for all functions in the SDK.

0 commit comments

Comments
 (0)