Skip to content

Instantly share code, notes, and snippets.

@AzimUddin
AzimUddin / HDInsight_Cluster_Customization_Via_SDK.cs
Last active August 29, 2015 14:00
An Example of HDInsight Cluster customization via HDInsight .Net SDK
/*1. Create a Visual studio 2012 Project.
2. Add HDInsight SDK NuGet to your project -
In Visual Studio 2012, Click on Tools -> library package manager -> Package Manager Console
PM> Install-Package Microsoft.WindowsAzure.Management.HDInsight
3. Use the following code, fill up the relevant info, then build and run -
*/
using System;
using System.Collections.Generic;
using System.Linq;
@AzimUddin
AzimUddin / hadoop_config_via_rest_api.ps1
Created February 13, 2014 19:15
Hadoop Job configurations via direct REST API call
# An Example of using passing hadoop configurations for a job in HDInsight, via direct REST API
$MyHDInsightUserName = "YourClusterUserName"
$MyHDInsightPwd = "YourPwd"
$clusterName = "YourClusterName"
$storageAcctname = "YourStorageAcctname"
$containerName = "YourDefaultContainerName"
$HdInsightPwd = ConvertTo-SecureString $MyHDInsightPwd -AsPlainText -Force
$HdInsightCreds = New-Object System.Management.Automation.PSCredential ($MyHDInsightUserName, $HdInsightPwd)
@AzimUddin
AzimUddin / HadoopJobConfig_HDI_SDK.cs
Last active August 29, 2015 13:56
Hadoop job configurations via HDInsight .Net SDK
var mapReduceJob = new MapReduceJobCreateParameters()
{
ClassName = "wordcount", // required
JobName = "MyWordCountJob", //optional
JarFile = "/example/jars/hadoop-examples.jar", // Required, alternative syntax: wasb://hdijobs@azimasv2.blob.core.windows.net/example/jar/hadoop-examples.jar
StatusFolder = "/AzimMRJobs/WordCountJobStatus" //Optional, but good to use to know where logs are uploaded in Azure Storage
};
//WordCount progam needs two arguments
mapReduceJob.Arguments.Add("/example/data/gutenberg/davinci.txt"); //input file
@AzimUddin
AzimUddin / HadoopConfig_HDI_PowerShell.ps1
Last active August 29, 2015 13:56
Hadoop job configurations with HDinsight PowerShell
# mapreduce example with hadoop job configurations
$clusterName = "YourClusterName"
$jobConfig = @{ "mapred.output.compress"="true"; "mapred.output.compression.codec"="org.apache.hadoop.io.compress.GzipCodec" }
$myWordCountJob = New-AzureHDInsightMapReduceJobDefinition -JarFile "/example/jars/hadoop-examples.jar" -ClassName "wordcount" -jobName "WordCountJob" -StatusFolder "/MyMRJobs/WordCountJobStatus" -Defines $jobConfig
$myWordCountJob.Arguments.Add("/example/data/gutenberg/davinci.txt")
$myWordCountJob.Arguments.Add("MyMRJobs/WordCountOutput")
$MyMRJob = Start-AzureHDInsightJob -Cluster $clusterName -JobDefinition $myWordCountJob
#Hive Job example with hadoop job configurations
$clusterName = "YourClusterName"