Skip to content

Instantly share code, notes, and snippets.

@ErikAndreas
ErikAndreas / choco.md
Created August 14, 2018 09:03
Chocolatey

Install chocolatey per instructions on site

cinst packages.config -y

@ErikAndreas
ErikAndreas / build.yml
Last active October 24, 2024 21:21
Static angular site Azure DevOps pipeline Static web site deploy to Azure blob GPv2. Define variables (jsonpath) for file transform
pool:
vmImage: Hosted Ubuntu 1604
demands: npm
steps:
- task: Npm@1
displayName: 'npm install'
inputs:
verbose: false
@ErikAndreas
ErikAndreas / build.yml
Created March 13, 2019 09:02
.net core 2 azure functions function app Azure pipeline deploy to Azure function app, also see https://medium.com/microsoftazure/serverless-devops-and-ci-cd-part-2-b6e0a6d05530
pool:
vmImage: Hosted Ubuntu 1604
steps:
- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: restore
projects: '$(Parameters.RestoreBuildProjects)'
@ErikAndreas
ErikAndreas / client.js
Created March 21, 2019 08:40
Azure Functions SignalR service authentication using imperative ("dynamic") binding of userId for negotiate, assuming jwt is set from client using accessTokenFactory. Use case when not using app service authentication.
const connection = new signalR.HubConnectionBuilder()
.withUrl('http://localhost:7071/api/v1.0/messages/binding',
{ accessTokenFactory: () => "aJwtToken" })
.build();
@ErikAndreas
ErikAndreas / DatePeriod.cs
Last active September 14, 2021 11:39
Get DateTimes relative Now from Parsing text period, e.g. "Sun 18:00 - Mon 06:00" provided current datetime
using System;
using System.Globalization;
public class Program
{
public static void Main()
{
//string inputStr = "Tue 18:00-Wed 06:00";
string inputStr = "Sat 18:00-Mon 06:00";
var now = DateTime.Parse("2021-08-30 06:01:00");
@ErikAndreas
ErikAndreas / sql.md
Last active February 5, 2022 15:41
Azure function using Azure Active Directory managed identity to authenticate with Azure SQLServer in Azure and working transparently locally. Using Dapper as ORM.

"Your account control strategy should rely on identity systems for controlling access rather than relying on network controls or direct use of cryptographic keys" - Microsoft Well Architected framework Security pillar

Context and steps

  1. Create Azure SQLServer and database, only allow AAD auth
  2. Set AAD admin, preferably a group account and add whoever needs admin access
  3. Set firewall rules
  4. Test connection with e.g. SSMS using AAD - universal with mfa login
  5. Create a table ('test' is used here)
  6. Create function app, http triggered VS 2022, copy code from here