Skip to content

Instantly share code, notes, and snippets.

Justin Yoo justinyoo

View GitHub Profile
@justinyoo
justinyoo / app-module.cs
Last active Feb 21, 2019
Revising Azure Functions Dependency Injection
View app-module.cs
public class AppModule : Module
{
public override void Load(IServiceCollection services)
{
services.AddSingleton<AppSettings>();
services.AddTransient<IGetSamplesFunction, GetSamplesFunction>();
}
}
@justinyoo
justinyoo / local-settings.json
Last active Feb 4, 2019
Introducing Swagger UI on Azure Functions
View local-settings.json
{
"IsEncrypted": false,
"Values": {
...
"OpenApi__Info__Version": "2.0.0",
"OpenApi__Info__Title": "Open API Sample on Azure Functions",
"OpenApi__Info__Description": "A sample API that runs on Azure Functions either 1.x or 2.x using Open API specification.",
"OpenApi__Info__TermsOfService": "https://github.com/aliencube/AzureFunctions.Extensions",
"OpenApi__Info__Contact__Name": "Aliencube Community",
"OpenApi__Info__Contact__Email": "no-reply@aliencube.org",
@justinyoo
justinyoo / functionapp.tf
Created Jan 16, 2019
Terraforming Azure PaaS
View functionapp.tf
# functionapp.tf
#
# Configure the Azure Provider
provider "azurerm" {
version = "=1.20.0"
}
locals {
name = "${var.name}"
location = "${var.location}"
@justinyoo
justinyoo / endpoint.cs
Created Jan 10, 2019
Domain Specific Language with Fluent API
View endpoint.cs
public static IFunctionFactory Factory { get; set; } = new FunctionFactory(new AppModule());
[FunctionName(nameof(XmlToXmlMapperHttpTrigger))]
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "mappers/xml/xml")] HttpRequestMessage req,
ILogger log)
{
return result = await Factory.Create<IXmlToXmlMapperFunction, ILogger>(log)
.InvokeAsync<HttpRequestMessage, HttpResponseMessage>(req)
.ConfigureAwait(false);
@justinyoo
justinyoo / extension-object.xml
Created Jan 6, 2019
Building XSL Mapper with Azure Functions
View extension-object.xml
<ExtensionObjects>
<ExtensionObject
Namespace="http://schemas.microsoft.com/BizTalk/2003/ScriptNS0"
AssemblyName="Fully.Qualified.Assembly.Name, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d7e94ac1875c97e9"
ClassName="Fully.Qualified.Class.Name" />
</ExtensionObjects>
@justinyoo
justinyoo / render-swagger-function.cs
Last active Jan 3, 2019
Rendering Swagger Definitions on Azure Functions
View render-swagger-function.cs
public class RenderSwaggerFunction : FunctionBase<ILogger>, IRenderSwaggerFunction
{
private readonly HttpClient _http;
...
public RenderSwaggerFunction(AppSettings settings, HttpClient http)
{
this._http = http ?? throw new ArgumentNullException(nameof(http));
...
}
@justinyoo
justinyoo / appmodule.cs
Created Jan 2, 2019
Accessing to Key Vault from Azure Functions with Managed Identity
View appmodule.cs
public class AppModule : Module
{
public override void Load(IServiceCollection services)
{
var azureServiceTokenProvider = new AzureServiceTokenProvider();
var kv = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
services.AddSingleton<IKeyVaultClient>(kv);
...
}
@justinyoo
justinyoo / appmodule.cs
Last active Jan 1, 2019
AutoMapper DI into Azure Functions
View appmodule.cs
public class AppModule : Module
{
public override void Load(IServiceCollection services)
{
...
services.AddAutoMapper(Assembly.GetAssembly(this.GetType()));
...
}
}
@justinyoo
justinyoo / locale-default.cs
Created Dec 30, 2018
Locale Settings in Azure Functions
View locale-default.cs
[FunctionName(nameof(Default))]
public static async Task<IActionResult> Default(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "locale/default")] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
var body = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(body);
@justinyoo
justinyoo / install-azure-cli.sh
Created Dec 27, 2018
Running Docker and Azure CLI from WSL
View install-azure-cli.sh
# This works on WSL - Ubuntu 18.04 LTS
# Add repository
sudo apt-get install apt-transport-https lsb-release software-properties-common -y
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | \
sudo tee /etc/apt/sources.list.d/azure-cli.list
# Install Microsoft signing key
wget https://packages.microsoft.com/keys/microsoft.asc
sudo apt-key add microsoft.asc
You can’t perform that action at this time.