Skip to content

Instantly share code, notes, and snippets.

@gbellmann
gbellmann / project.json
Created September 11, 2016 17:58
Sample Azure Functions C# project.json file
{
"frameworks": {
"net46":{
"dependencies": {
"Microsoft.Azure.Search": "2.0.4-preview"
}
}
}
}
@gbellmann
gbellmann / function.json
Created September 6, 2016 01:44
Azure Functions configuration file
{
"disabled":false,
"bindings":[
// aquí van los bindings
{
"type": "bindingType",
"direction": "in",
"name": "myParamName",
// ... más, dependiendo del binding ...
}
protected override async Task RunAsync(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
ServiceEventSource.Current.ServiceMessage(this, "Hello World at " + DateTime.Now.ToLongTimeString());
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
}
}
@gbellmann
gbellmann / HelloWorldService.cs
Created August 31, 2016 21:55
Service Fabric Stateless Service newly created from the template
using System;
using System.Collections.Generic;
using System.Fabric;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ServiceFabric.Services.Communication.Runtime;
using Microsoft.ServiceFabric.Services.Runtime;
namespace HelloWorldService
$subscriptionName = "<AzureSubscriptionName>" # La suscripción de Azure usada para la creación del clúster HDInsight
$storageAccountName = "<AzureStorageAccountName>" # El clúster HDInsight necesita de una cuenta de Azure Storage para el sistema de archivos por defecto
$clusterName = "<HDInsightClusterName>" # El nombre del clúster HDInsight a crear
$clusterNodes = <ClusterSizeInNodes> # El número de nodos del clúster HDInsight
$hadoopUserName = "<HadoopUserName>" # Nombre de usuario para Hadoop. Es el usuario que se utilizará para conectarse al clúster y correr trabajos en él.
$hadoopUserPassword = "<HadoopUserPassword>"
$secPassword = ConvertTo-SecureString $hadoopUserPassword -AsPlainText -Force
$storageAccountName = "<StorageAccountName>" # Nombre de la cuenta de Storage
$containerName="<ContainerName>" # Nombre del Contenedor que crearemos
# Creamos el objeto de contexto que representa a la cuenta de Storage
$storageAccountKey = Get-AzureStorageKey $storageAccountName | %{ $_.Primary }
$destContext = New-AzureStorageContext -StorageAccountName $storageAccountName
-StorageAccountKey $storageAccountKey
# Creamos el Contenedor en Blob storage
New-AzureStorageContainer -Name $containerName -Context $destContext
$storageAccountName = "<StorageAcccountName>" # Nombre de la cuenta de Storage
$location = "<MicrosoftDataCenter>" # Por ejemplo, "East US"
# Crear una cuenta de Azure Storage
New-AzureStorageAccount -StorageAccountName $storageAccountName -Location $location
Add-AzureAccount
@gbellmann
gbellmann / CreateCluster.cs
Created October 7, 2015 23:28
Create a basic Hadoop cluster in HDInsight
using System;
using System.Security.Cryptography.X509Certificates;
using Microsoft.WindowsAzure.Management.HDInsight;
namespace Hdinsight
{
public static class Helpers
{
private static readonly Guid SubscriptionId = new Guid("<subscription id>");
private const string CertThumbprint = "<certificate thumbprint>";
@gbellmann
gbellmann / FindCertificate.cs
Last active September 2, 2015 16:01
Find X.509 certificate from store
public X509Certificate2 FindCertificate(StoreLocation storeLocation, StoreName storeName, X509FindType findType, object searchCriteria)
{
X509Store certificateStore = new X509Store(storeName, storeLocation);
certificateStore.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certificates = certificateStore.Certificates;
X509Certificate2Collection matchingCertificates = certificates.Find(findType, searchCriteria, false);
if (matchingCertificates != null && matchingCertificates.Count > 0)
{
return matchingCertificates[0];
}