Skip to content

Instantly share code, notes, and snippets.

Function Using-Object(
[System.IDisposable]
$InputObject,
[scriptblock]
$ScriptBlock = {throw "ScriptBlock is mandatory, please provide a value."})
{
try
{
. $ScriptBlock
#This function generate auth token using azure sdk
Function GetAuthTokenUsingAzureSdk {
Param (
[Parameter(Mandatory)][ValidateNotNull()][ValidateNotNullOrEmpty()]
[String]$apiEndpointUri,
[Parameter(Mandatory)][ValidateNotNull()][ValidateNotNullOrEmpty()]
[String]$tenantId,
[Parameter(Mandatory)][ValidateNotNull()][ValidateNotNullOrEmpty()]
[String]$applicationId,
[Parameter(Mandatory)][ValidateNotNull()][ValidateNotNullOrEmpty()]
@jeevan-vj
jeevan-vj / storage-account-out-connectionstring-withSAS.json
Created July 29, 2019 10:38
Create storage account and container and out put connection strings
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"variables": {
"storageAccountApiVersion": "2018-07-01",
"storageAccountNameTidy": "[toLower(trim(parameters('storageAccountName')))]",
"blobEndPoint":"[concat('https://',variables('storageAccountNameTidy'),'.blob.core.windows.net/')]"
},
"parameters": {
"location": {
"resources": [
{
"name": "[parameters('storageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "[variables('storageAccountApiVersion')]",
"location": "[parameters('location')]",
"properties": {
"accessTier": "[parameters('accessTier')]",
"supportsHttpsTrafficOnly": "[parameters('supportsHttpsTrafficOnly')]"
},
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"functions": [
{
"namespace": "rt",
"members": {
"containerNameWithLocation": {
"parameters": [
{
@jeevan-vj
jeevan-vj / copy-direcotry-recursive-msbuild.xml
Created July 25, 2019 09:00
Copy directory recursively in Ms Build
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<CloudArtifacts Include=".Cloud\Data\**\*.*"/>
</ItemGroup>
<Target Name="CopyFiles">
<Copy SourceFiles="@(CloudArtifacts)" DestinationFiles="@(CloudArtifacts->'c:\PackableFiles\%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>
@jeevan-vj
jeevan-vj / ServicePrinciplePowershell.ps1
Created July 15, 2019 08:55
Create Service Principal in Powershell and login to azure
#Create AD app
$dummyUrl = "https://dummy.dummy.com"
$passpowrd = "Qwerty@123!"
$securePassword = ConvertTo-SecureString -String $passpowrd -AsPlainText -Force
$app = New-AzureRmADApplication -DisplayName $dummyUrl `
-IdentifierUris $dummyUrl `
-HomePage $dummyUrl `
-Password $securePassword -Verbose
#Login with service principal
$clientId = "<CLIENT ID>"
$credentials = New-Object System.Management.Automation.PSCredential ($clientId, $securePassword)
Login-AzureRmAccount -ServicePrincipal -TenantId "<TENANTID>" `
-SubscriptionId "<SUBSCRIPTIONID>" `
-Credential $credentials
@jeevan-vj
jeevan-vj / CreateServicePrincipal.ps1
Created July 15, 2019 08:41
Create Service Principal
#Create Service principal
New-AzureRmADServicePrincipal -ApplicationId $app.ApplicationId `
-DisplayName $dummyUrl `
-Password $securePassword `
-Scope "/subscriptions/<SUBSCRIPTION ID>" `
-Role Contributor `
-StartDate ([datetime]::Now) `
-EndDate $([datetime]::now.AddYears(1)) -Verbose
@jeevan-vj
jeevan-vj / CreateADApp.ps1
Created July 15, 2019 08:35
Create ADD App
#Create AD app
$dummyUrl = "https://dummy.dummy.com"
$passpowrd = "Qwerty@123!"
$securePassword = ConvertTo-SecureString -String $passpowrd -AsPlainText -Force
$app = New-AzureRmADApplication -DisplayName $dummyUrl `
-IdentifierUris $dummyUrl `
-HomePage $dummyUrl `
-Password $securePassword -Verbose