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
int throughputCurrent = (int)offer.GetPropertyValue<JObject>("content").GetValue("offerThroughput");
log.LogInformation(string.Format("Current provisioned throughput is: {0} RU", throughputCurrent.ToString()));
Offer offer = client.CreateOfferQuery().Where(r => r.ResourceLink == selfLink).AsEnumerable().SingleOrDefault();
@sajeetharan
sajeetharan / 6182019_cosmos_scale_client_self
Last active June 18, 2019 07:20
Get self link cosmosdb
string selfLink = client.CreateDocumentCollectionQuery(UriFactory.CreateDatabaseUri(config["CosmosDB_DatabaseId"]))
.Where(c => c.Id == config["CosmosDB_ContainerId"])
.AsEnumerable()
.FirstOrDefault()
.SelfLink;
@sajeetharan
sajeetharan / 6182019_cosmos_scale_client
Last active June 18, 2019 07:21
Creating cosmosdb client
var config = new ConfigurationBuilder().SetBasePath(context.FunctionAppDirectory)
.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
//1) initialize the cosmosdb client
using (DocumentClient client = new DocumentClient(new Uri(config["CosmosDB_Uri"]), config["CosmosDB_appKey"]))
import { HttpClient, HttpHeaders } from "@angular/common/http";
import * as Cosmos from "@azure/cosmos";
import * as Model from "../models/todoItem";
export class CosmosService {
private static instance: CosmosService;
private readonly cosmosHost = "<your_db>.documents.azure.com:443/";
private readonly primaryKey = "<primary_key>";
import { Component } from '@angular/core';
import * as CS from '../cosmos-service';
import * as Model from '../../models/todoItem';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
export interface Todo {
id?: string;
description: string;
userId: string;
completed?: boolean;
type : string;
}
export interface TodoCollection {
Documents: Todo[];
@sajeetharan
sajeetharan / gist:810ee8d369dd1fc420b0e49b94b0abd0
Created May 6, 2019 13:27
Upload to storage blob and cosmosdb
using System;
using System.IO;
using System.Threading.Tasks;
using JourneyEntities;
using Microsoft.Azure.Documents.Client;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.WindowsAzure.Storage;
AccountEndpoint=https://asrdemo-Cosmosdb.documents.azure.com:443/;AccountKey=fU5dxjtsdasthasaawr4NsrwMiDPTR06ybrhn5Hffs23452diV77zd1RjI75nMNLX5QQ==;database=migrationDemo
SELECT
CAST(BusinessEntityID AS varchar) AS [id],
Name AS [name],
AddressType AS [address.addressType],
AddressLine1 AS [address.addressLine1],
City AS [address.location.city],
StateProvinceName AS [address.location.stateProvinceName],
PostalCode AS [address.postalCode],
CountryRegionName AS [address.countryRegionName]
FROM