Skip to content

Instantly share code, notes, and snippets.

View sajeetharan's full-sized avatar
💭
Debugging "Object reference not set to an instance of an object." 😬

Sajeetharan sajeetharan

💭
Debugging "Object reference not set to an instance of an object." 😬
View GitHub Profile
$rsgName = "xxxxx"
$appName = "xxxxx"
$slotName = "xxxxxx"
$destination = Get-AzureRmWebApp -ResourceGroupName $rsgName -Name $appName
$destinationAppSettings = $destination.SiteConfig.AppSettings
$destinationConnectionStrings = $destination.SiteConfig.ConnectionStrings
$source = Get-AzureRmWebAppSlot -ResourceGroupName $rsgName -Name $appName -Slot $slotName
$sourceAppSettings = $source.SiteConfig.AppSettings
@sajeetharan
sajeetharan / metaprops
Created November 16, 2019 02:35
Remove meta props from cosmosdb query
function stripMeta(doc) {
var metaProps = ["_rid", "_ts", "_self", "_etag", "_attachments"];
var newDoc = {};
for(var prop in doc) {
if (metaProps.indexOf(prop) == -1) {
newDoc[prop] = doc[prop];
}
}
return newDoc;
@sajeetharan
sajeetharan / Add-UserEntitlement.ps1
Created November 5, 2019 12:25
Add-UserEntitlement.ps1
<#
.Synopsis
Short description
.DESCRIPTION
Long description
.EXAMPLE
Example of how to use this cmdlet
.EXAMPLE
Another example of how to use this cmdlet
#>
namespace Naos.Foundation.Infrastructure
{
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Net;
using System.Threading.Tasks;
using EnsureThat;
using Humanizer;
using Microsoft.Azure.Cosmos;
@sajeetharan
sajeetharan / FilesFilter.py
Created September 1, 2019 08:06
Filter the files from datalake based on the parameters
import os
from datetime import *
class FilesFilter():
"""
filter to get file list in a folder, which file modification time between[start_date,end_date]
"""
@staticmethod
def get_files_list(path_to_folder,start_date=None,end_date=None):
file_list = []
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appServiceName": {
"type": "string",
"minLength": 1
},
"appServiceSkuName": {
"type": "string",
// store our master key for documentdb
var mastKey = postman.getEnvironmentVariable("CosmosDBMasterKey");
console.log("mastKey = " + mastKey);
// store our date as RFC1123 format for the request
var today = new Date();
var UTCstring = today.toUTCString();
postman.setEnvironmentVariable("RFC1123time", UTCstring);
// Grab the request url
@sajeetharan
sajeetharan / 6242019_dev_podcasts
Last active June 24, 2019 17:51
List of tech podcasts
General
https://blog.codepen.io/radio/
http://softwareengineeringdaily.com/
http://spec.fm/
https://syntax.fm/
http://www.codingblocks.net/
http://devhell.info/
http://www.fullstackradio.com/
https://www.functionalgeekery.com/
http://reactive.audio/
@sajeetharan
sajeetharan / 6182019_cosmos_scale_client_scale
Last active June 18, 2019 07:19
Cosmosdb autoscale (up/down by setting RU)
public static class Cosmosscale
{
[FunctionName("Cosmosscale")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log,
ExecutionContext context)
{
try
//5) Get the RU increment from AppSettings and parse to an int
if (int.TryParse(config["CosmosDB_RU"], out int RUIncrement))
{
//5.a) create the new offer with the throughput increment added to the current throughput
int newThroughput = throughputCurrent + RUIncrement;
offer = new OfferV2(offer, newThroughput);
//5.b) persist the changes
await client.ReplaceOfferAsync(offer);
log.LogInformation(string.Format("New provisioned througput: {0} RU", newThroughput.ToString()));