Skip to content

Instantly share code, notes, and snippets.

@rithala
rithala / deploy-azfunc.ps1
Last active May 19, 2020 14:06
Deploy Az Function PowerShell
#=============Defining All Variables=========
$location = 'West Europe'
$resourceGroupName = 'functionrgnew1'
$storageAccount = 'functionsasdnewqq1'
$subscriptionId = '<id>'
$functionAppName = 'functionapppsdfsdnew1'
$appInsightsName = 'appinsightnameprdad'
$appServicePlanName = 'functionappplan'
$appPackage = '.\package.zip'
$tier = 'Dynamic'
@rithala
rithala / azure-pipelien.yml
Created May 19, 2020 14:09
Gatsby Azure DevOps pipeline
trigger:
branches:
include:
- master
- develop
paths:
include:
- src/SPA/*
exclude:
- src/SPA/README.md
@rithala
rithala / azure-pipelines.yml
Last active June 2, 2020 13:26
Azure Function Azure DevOps pipeline
# .NET Core Function App to Windows on Azure
# Build a .NET Core function app and deploy it to Azure as a Windows function App.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/dotnet-core
trigger:
branches:
include:
- master
- develop
@rithala
rithala / Clear-AcrRepository.ps1
Created May 19, 2020 14:20
Purge Azure Container Repository
# WARNING! This script deletes data!
# Run only if you do not have systems
# that pull images via manifest digest.
Param(
[Parameter(Mandatory=$true)]
$registry,
[Parameter(Mandatory=$true)]
$repository,
[switch]
@rithala
rithala / Create-SelfSignedCertificate.ps1
Created May 19, 2020 14:21
Create Self-Signed Certificate for Azure AD App Registration
#Requires -RunAsAdministrator
<#
.SYNOPSIS
Creates a Self Signed Certificate for use in server to server authentication
.DESCRIPTION
.EXAMPLE
.\Create-SelfSignedCertificate.ps1 -CommonName "MyCert" -StartDate 2015-11-21 -EndDate 2017-11-21
This will create a new self signed certificate with the common name "CN=MyCert". During creation you will be asked to provide a password to protect the private key.
.EXAMPLE
.\Create-SelfSignedCertificate.ps1 -CommonName "MyCert" -StartDate 2015-11-21 -EndDate 2017-11-21 -Password (ConvertTo-SecureString -String "MyPassword" -AsPlainText -Force)
@rithala
rithala / ConfidentialClientApplicationProvider.cs
Created May 22, 2020 11:04
Create Certificate Based Azure AD ConfidentialClientApplicationProvider
using Azure.Security.KeyVault.Certificates;
using Azure.Security.KeyVault.Secrets;
using Microsoft.Identity.Client;
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
namespace Sii.CloudSync.Core.Infrastructure.Configuration.AzureAD
{
internal class ConfidentialClientApplicationProvider : IDisposable
@rithala
rithala / Basic-WebRequest.ps1
Last active November 6, 2023 09:06
PowerShell HTTP Request with Basic Auth
$user = 'user'
$pass = 'pass'
$uri = '<url>'
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
@rithala
rithala / RestResponse.cs
Last active May 28, 2020 09:24
REST Response Class
namespace YourNamespace
{
public abstract class BaseResponse
{
public bool IsError { get; }
protected BaseResponse(bool isError)
{
IsError = isError;
}