Skip to content

Instantly share code, notes, and snippets.

@JCallico
JCallico / Upload-FileToADLS.ps1
Last active February 11, 2022 16:38
Powershell script to upload a file incrementally to an Azure Data Lake Storage using OAuth2 authentication
[CmdletBinding()]
Param(
# OAuth parameters
[Parameter(Mandatory = $false)] [string] $TenantID = 'a guid',
[Parameter(Mandatory = $false)] [string] $ClientID = 'a client id',
[Parameter(Mandatory = $false)] [string] $Scope = 'https://storage.azure.com/.default',
[Parameter(Mandatory = $false)] [string] $GrantType = 'client_credentials',
[Parameter(Mandatory = $false)] [string] $ClientSecret = '',
[Parameter(Mandatory = $false)] [string] $ClientSecretKeyVaultSecret = 'the secret name',
[Parameter(Mandatory = $false)] [string] $KeyVaultName = 'the key vault name',
@JCallico
JCallico / SqlExecTime.ps1
Created April 27, 2021 13:59
Executes *.sql files and times the execution
# Sample Usage: .\SqlExecTime.ps1 -Server "LOCALHOST" -Database "WideWorldImportersDW" -Integrated
# Prerequisites: Install-Module -Name SqlServer -AllowClobber
# To do: add support for Access Token authentication
param (
[Parameter(Mandatory=$false)]$Server,
[Parameter(Mandatory=$false)]$Database,
[Parameter(Mandatory=$false)]$Username,
[Parameter(Mandatory=$false)]$Password,
[Parameter(Mandatory=$false)]$Path,
@JCallico
JCallico / Create DB Sync Group.ps1
Last active October 10, 2017 13:46
Use PowerShell to sync between an Azure SQL Database and a SQL Server on-premises database [Rev 1]
# prerequisites:
# 1. Create an Azure Database from AdventureWorksLT sample database as hub database
# 2. Create an Azure Database in the same region as sync database
# 3. Create an on premises SQL Server Database as member database
# 4. Update the parameters below before running the sample
#
using namespace Microsoft.Azure.Commands.Sql.DataSync.Model
using namespace System.Collections.Generic
# Hub database info
@JCallico
JCallico / SB_AT_Installation.sql
Last active January 15, 2018 18:42
Service Broker Sample 8: Asynchronous Triggers [Modified] Original can be found at http://www.madeiradata.com/service-broker-asynchronous-triggers
/*
===========================================================================
Service Broker Sample 2: Asynchronous Triggers
===========================================================================
Source code: https://gist.github.com/JCallico/8182ab062d8dd7fd7c06bd023faf08ec
Based on: http://www.madeiradata.com/service-broker-asynchronous-triggers
*/
-- Creation of the table for global settings
internal class OAuthAuthorizationServerHandler : AuthenticationHandler<OAuthAuthorizationServerOptions>
{
private Task SendErrorAsJsonAsync(
BaseValidatingContext<OAuthAuthorizationServerOptions> validatingContext)
{
string error = validatingContext.HasError ? validatingContext.Error : Constants.Errors.InvalidRequest;
string errorDescription = validatingContext.HasError ? validatingContext.ErrorDescription : null;
string errorUri = validatingContext.HasError ? validatingContext.ErrorUri : null;
var memory = new MemoryStream();
public HttpCookie Get(String name) {
HttpCookie cookie = (HttpCookie)BaseGet(name);
if (cookie == null && _response != null) {
// response cookies are created on demand
cookie = new HttpCookie(name);
AddCookie(cookie, true);
_response.OnCookieAdd(cookie);
}