Skip to content

Instantly share code, notes, and snippets.

View briandenicola's full-sized avatar

Brian briandenicola

View GitHub Profile
@briandenicola
briandenicola / search.config.cs
Last active September 28, 2021 22:03
Azure Search Code Samples
using System;
using Azure;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Microsoft.Azure.Search;
using Microsoft.Azure.Search.Models;
using Azure.Search.Documents;
using Azure.Search.Documents.Indexes;
using Azure.Search.Documents.Indexes.Models;
@briandenicola
briandenicola / gist:f149d59acb3d44e2590e527234365fea
Created June 22, 2020 03:23
Kubectl to Roll Deployment via REST API
kubectl proxy
curl -X PATCH -d "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"date\":\"`date +'%s'`\"}}}}}" -H 'Content-Type: application/strategic-merge-patch+json' http://localhost:8001/apis/apps/v1/namespaces/default/deployments/demo
{
"type": "Microsoft.ApiManagement/service/gateways",
"apiVersion": "2019-12-01",
"name": "[concat(parameters('apimName'), '/demo')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service', parameters('apimName'))]"
],
"properties": {
"locationData": {
"name": "Dallas"
@briandenicola
briandenicola / gist:9e6716bd0cb071818c9a28324e7262fc
Created June 8, 2020 19:55
Azure AD Authentication with .net 3.1
startup.cs
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.AzureAD.UI;
services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
.AddAzureAD(options => Configuration.Bind("AzureAd", options));
services.AddControllersWithViews(options =>
{
export PAT=''
export DB-WORKSPACE=''
export WHITELIST='1.1.1.1/32'
#Enable
curl -X PATCH -H "Authorization: Bearer ${PAT}" https://${DB-WORKSPACE}/api/2.0/preview/workspace-conf?keys=enableIpAccessLists -d '{ "enableIpAccessLists": "true", }'
#Create
curl -X PUT -H 'Authorization: Bearer ${PAT}' https://${DB-WORKSPACE}/api/2.0/preview/ip-access-lists -d "{ \"label\": \"home\", \"list_type\": \"WHITELIST\", \"ip_addresses\": [ $WHITELIST ] }"
@briandenicola
briandenicola / Azure APIM Help Function
Created May 7, 2020 15:07
A quick and dirty function to help with Azure APIM with Invoke-RestMethod
function New-APIMHeader {
param(
[string] $key
)
$header = @{}
$header.Add('Ocp-Apim-Subscription-Key', $Key)
return $header
}

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@briandenicola
briandenicola / Get SP List
Created April 5, 2013 16:35
These are two simple functions that I use on a daily basis to interact with a SharePoint List - Get List Items and Create a New List Item. The parameters for Get-SPListViaWebService are pretty straight forward. The URL is the URL of the SharePoint Web were the list resides. If a view GUID is not passed then the list items in the default view are…
function Get-SPListViaWebService( [string] $url, [string] $list, [string] $view = $null )
{
begin {
$listData = @()
$service = New-WebServiceProxy (Get-WebServiceURL -url $url) -Namespace List -UseDefaultCredential
$FieldsWS = $service.GetList( $list )
$Fields = $FieldsWS.Fields.Field | where { $_.Hidden -ne "TRUE"} | Select DisplayName, StaticName -Unique
$data = $service.GetListItems( $list, $view, $null, $null, $null, $null, $null )
}
process {