Skip to content

Instantly share code, notes, and snippets.

View KaiWalter's full-sized avatar

Kai Walter KaiWalter

View GitHub Profile
@KaiWalter
KaiWalter / gitPullAllSubDirectories.PS1
Created June 9, 2016 05:57
PowerShell script to pull for all subdirectories
Get-ChildItem -Directory | ForEach {
Write-Host "PULLING" $_.name
Push-Location
Set-Location $_.name
git pull
@KaiWalter
KaiWalter / DirectoryCleaner.cs
Created June 14, 2016 17:54
Azure B2C replace DisplayName=Unkown with FirstName+LastName
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System.Net.Http;
using System.Net.Http.Headers;
@KaiWalter
KaiWalter / run.csx
Created December 13, 2016 06:46
setup Forward from Azure Service Bus Subscription to a similarly named Queue with an Azure Function
#r "Microsoft.ServiceBus"
using System;
using System.Text;
using System.Net;
using System.Net.Http;
using Microsoft.ServiceBus;
public static HttpResponseMessage Run(HttpRequestMessage req, TraceWriter log)
{
@KaiWalter
KaiWalter / msLinks.PS1
Created December 30, 2016 13:45
PowerShell small menu script for links
@KaiWalter
KaiWalter / ServiceFabric.FunctionHost.sfproj
Last active July 24, 2017 19:32
Functions Console host as Service Fabric Guest Executable
<ItemGroup>
<Content Include="..\..\azure-webjobs-sdk-script\src\WebJobs.Script.Host\bin\Release\**\*.*">
<Link>ApplicationPackageRoot\FunctionHostPkg\Code\%(RecursiveDir)%(Filename)%(Extension)</Link>
</Content>
<Content Include="ApplicationPackageRoot\FunctionHostPkg\Code\___SetupDataFolder.bat" />
<Content Include="ApplicationPackageRoot\FunctionHostPkg\Config\Settings.xml" />
<Content Include="ApplicationPackageRoot\FunctionHostPkg\Data\host.json" />
<Content Include="ApplicationPackageRoot\FunctionHostPkg\Data\ServiceBusQueueTrigger\function.json" />
<Content Include="ApplicationPackageRoot\FunctionHostPkg\Data\ServiceBusQueueTrigger\index.js" />
<Content Include="ApplicationPackageRoot\FunctionHostPkg\Data\TimerTrigger\function.json" />
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"networkInterfaceName": {
"type": "string"
},
import datetime
filename = os.environ.get('TEMP') + '\\results_' + datetime.datetime.utcnow().replace(microsecond=0).isoformat().replace(':','') + '.xlsx'
operationResults.to_excel(filename)
print('created file',filename)
@KaiWalter
KaiWalter / configureApiManagement2Cluster.PS1
Created February 17, 2019 08:06
create API Management certificates and back-end objects to connect to Service Fabric
# random character combination generator for the certificate password
function Get-RandomCharacters($length, $characters) {
$random = 1..$length | ForEach-Object { Get-Random -Maximum $characters.length }
$private:ofs = "" # set ouput field separator
return [String]$characters[$random]
}
# creates a new APIM to SF client certificate
function New-ClientCertificate() {
param(
@KaiWalter
KaiWalter / downloadWebHostSource.PS1
Created February 17, 2019 08:08
download Azure Functions WebHost source code
param(
[string]$DownloadBuildNumber
)
$url = "https://github.com/Azure/azure-functions-host/archive/" + $DownloadBuildNumber + ".zip"
$url2 = "https://github.com/Azure/azure-functions-host/archive/v" + $DownloadBuildNumber + ".zip"
$targetZip = Join-Path $PSScriptRoot "WebHost.zip"
if (Test-Path $targetZip) {
@KaiWalter
KaiWalter / cleanUpResourceGroupDeployments.PS1
Created March 20, 2019 04:54
remove ResourceGroupDeployments up to a given limit
param(
[Parameter(Mandatory = $false, Position = 1)]
[int]
$Keep = 100
)
Get-AzureRmResourceGroup | ForEach-Object {
$ts = (Get-AzureRmResourceGroupDeployment -ResourceGroupName $_.ResourceGroupName |
Sort-Object Timestamp -Descending |
Select-Object -First $Keep |