Skip to content

Instantly share code, notes, and snippets.

@alexeldeib
alexeldeib / sdk-cli-update.md
Last active January 26, 2021 18:09
App Insights and Log Analytics SDK + CLI Update

Application Insights Query SDK

The [Microsoft.Azure.ApplicationInsights NuGet package][1] contains the query SDK for App Insights. Here's a bare-minimum setup with a client ready to make calls:

AAD Authentication

using System;
using Microsoft.Azure.ApplicationInsights;
using Microsoft.Rest.Azure.Authentication;
using System.Collections.Generic;
@alexeldeib
alexeldeib / create-saved-search.ps1
Created April 30, 2018 22:14
Log Analytics Powershell create saved search (new query language)
$SubscriptionId = "dcc1e4f0-f18b-405e-85d7-1bab42e085d0"
$ResourceGroupName = "demo-rg"
$Workspace = "ExampleWS"
$SavedSearchId = [string]"$(New-Guid)"
$Category = "Patching"
$DisplayName = "Computers missing KB3023219"
$Query = 'Update | where KBID == "3023219" and UpdateState == "Needed" | distinct Computer'
$Version = "1"
$ResourceId = "subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.OperationalInsights/workspaces/$Workspace/savedSearches/$SavedSearchId"
@alexeldeib
alexeldeib / auth.ps1
Last active June 6, 2018 23:13
Azure Log Analytics - Create Service Principal and Authenticate to API
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$subscriptionId,
[Parameter(Mandatory=$True)]
[string]$resourceGroupName,
[Parameter(Mandatory=$True)]
[string]$workspaceName,
[Parameter(Mandatory=$True)]
[string]$aadAppName,
@alexeldeib
alexeldeib / runbook.ps1
Last active July 9, 2018 20:25
Azure Automation Log Analytics Query
workflow la-test
{
#The name of the Automation Credential Asset this runbook will use to authenticate to Azure.
$connectionName = "AzureRunAsConnection";
#Get the credential with the above name from the Automation Asset store
$servicePrincipalConnection = Get-AutomationConnection -Name $connectionName;
Write-Output $servicePrincipalConnection;
if(!$servicePrincipalConnection) {
@alexeldeib
alexeldeib / notes.md
Last active March 28, 2019 06:16
AKS Engine ContainerOS Debug

ContainerOS AKS Engine

Goals

  • Working example API model
  • Enable masters to form etcd cluster
  • Enable masters to form k8s cluster
  • Enable agents to join k8s cluster

Notes

@alexeldeib
alexeldeib / notes.md
Last active March 29, 2019 08:58
AKS Engine Custom VM Images from different subscription

Custom VM Images from different subscription

Required changes

  • add subscriptionId to customImage type
  • add subscription id to template
  • either always set subId (whether provided or not), or only put sub in arm template when provided

Test cases

  • Providing Master custom image in another subscription should work
@alexeldeib
alexeldeib / setup.sh
Last active June 17, 2020 22:45
Ubuntu setup script
#!/bin/bash
set -e
GOLANG_VERSION=1.13.8
# Basics
sudo apt update -y && sudo apt install -y apt-transport-https curl xclip git build-essential lsb-release gnupg < /dev/null
git config --global user.name "Ace Eldeib"
@alexeldeib
alexeldeib / Dockerfile
Created May 14, 2019 04:29
Dockerifle for controller-tools/controller-runtime/kubebuilder prow tests
FROM gcr.io/k8s-testimages/kubekins-e2e:v20190420-93fab49-master
RUN go get -u gopkg.in/alecthomas/gometalinter.v2 && gometalinter.v2 --install
RUN go get -u github.com/golang/dep/cmd/dep
RUN GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.16.0
RUN os=debian \
&& dist=stretch \
&& gpg_key_url="https://packagecloud.io/github/git-lfs/gpgkey" \
&& apt_source_path="/etc/apt/sources.list.d/github_git-lfs.list" \
@alexeldeib
alexeldeib / logs.md
Last active June 6, 2019 12:00
v0.1.1 capz logs

Update CAPI

ace@ace-x1:~/go/src/sigs.k8s.io/cluster-api-provider-azure$ git diff Gopkg.toml
diff --git a/Gopkg.toml b/Gopkg.toml
index bc606bf..7f68e05 100644
--- a/Gopkg.toml
+++ b/Gopkg.toml
@@ -52,7 +52,7 @@ required = [
 
 [[constraint]]
ace@ace-x1:~/go/src/sigs.k8s.io/cluster-api-provider-azure$ kubectl logs azure-provider-controller-manager-0 -n azure-provider-system -f
I0618 01:58:25.893921       1 plugins.go:39] Registered cluster provisioner "azure"
I0618 01:58:25.898359       1 reflector.go:131] Starting reflector *v1alpha1.Cluster (10m0s) from sigs.k8s.io/controller-runtime/pkg/cache/internal/informers_map.go:126
I0618 01:58:25.898432       1 reflector.go:169] Listing and watching *v1alpha1.Cluster from sigs.k8s.io/controller-runtime/pkg/cache/internal/informers_map.go:126
I0618 01:58:25.898682       1 reflector.go:131] Starting reflector *v1alpha1.Machine (10m0s) from sigs.k8s.io/controller-runtime/pkg/cache/internal/informers_map.go:126
I0618 01:58:25.898737       1 reflector.go:169] Listing and watching *v1alpha1.Machine from sigs.k8s.io/controller-runtime/pkg/cache/internal/informers_map.go:126
I0618 01:58:26.197648       1 cluster_controller.go:90] Running reconcile Cluster for "capi"
I0618 01:58:26.197800       1 machine_cont