Skip to content

Instantly share code, notes, and snippets.

View rndazurescript's full-sized avatar

R&D Azure Script rndazurescript

View GitHub Profile
@rndazurescript
rndazurescript / cleanup.adf.ps1
Created October 4, 2021 14:22
Clean up ADF resources
# Needs more testing. It worked in Azure cloud shell.
$deployResourceGroup="Your-ADF-Resource-Group-Name"
$deployDataFactoryName="Your-ADF-Resource-Name"
# Remove triggers
# If you don't want to remove them, you can comment out the the Remove.
# You will need to stop them, otherwise you will get the following error:
# Resource Microsoft.DataFactory/factories/triggers 'data-factory-name/Blob Created Trigger' failed with
# message '{ "error": { "code": "TriggerEnabledCannotUpdate", "message": "Cannot update enabled Trigger;
@rndazurescript
rndazurescript / AzureDevOps.yaml
Created April 5, 2021 13:48
Deploy Azure DevOps Agent in ACI
trigger: none
variables:
ResourceGroup: private-endpoint-demos-rg
vnetName: private-endpoint-vnet
vnetResourceGroup: $(ResourceGroup)
agentSubNetName: agents
location: westus2
imageName: azftademo/adoagent:ubuntu-18.04
storageContainerName: 'test'
@rndazurescript
rndazurescript / GetTokenToListBlobContainer.ps1
Last active February 22, 2021 14:39
Access storage account using managed identity on a VM
$stgaccount="ctenteststg"
$uri="http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://"+$stgaccount+".blob.core.windows.net"
$token=Invoke-RestMethod -Method GET -Uri $uri -Headers @{"Metadata"="True"}
$listContentUrl="https://"+$stgaccount+".blob.core.windows.net/testdata"
@rndazurescript
rndazurescript / VM-SKUs-With-Acc-Net.azcli
Created October 30, 2020 06:08
Azure VM SKUs with Accelerated Networking capability
az vm list-skus -o json --query '[].{name: name, caps: capabilities[? name==`AcceleratedNetworkingEnabled`]}[].{sku: name, acceleratedNetworking: caps[0].value}[? acceleratedNetworking == `True`]'
@rndazurescript
rndazurescript / GetAzureEndpoints.ps1
Created September 9, 2020 11:50
Get Azure Portal urls for proxy
Get-AzureRmEnvironment -Name AzureCloud | Format-List
@rndazurescript
rndazurescript / async_storage.py
Last active September 1, 2020 15:10
Accessing storage account in parallel using managed identity
# The following sample shows how to run async authentication and access to storage
# account. This sample suffers from the IMDS limit of 5 concurrent requests but
# the python SDK has baked in retry policies
import asyncio
import logging
import os
from azure.identity.aio import DefaultAzureCredential
from azure.storage.blob.aio import BlobServiceClient
import logging
@rndazurescript
rndazurescript / reboot.py
Created July 31, 2020 16:10
TPLink_Archer_C7_Router remote reboot script
import requests
import base64
import sys
ROUTER_IP = "192.168.0.1"
USERNAME = "admin"
PASSWORD = "YOUR_ROUTER_PASSWORD_HERE"
class TPLink_Archer_C7_Router_Web_Interface:
@rndazurescript
rndazurescript / OldAzureBobService.ts
Created July 14, 2020 12:13
Old blob uploader in typescript
module UpZure.Blob {
// An uploader client
// based on https://msdn.microsoft.com/en-us/library/azure/mt427365.aspx
// Limitations taken from https://msdn.microsoft.com/en-us/library/azure/dd135726.aspx
export class BlobUploader {
private MAX_BLOB_SIZE = 4 * 1024 * 1024;//Each file will be split in 4Mb (used to be 256 KB).
private BLOCK_NAME_PREFIX = "blk-";
private MAX_BLOCKS = 50000;//a maximum of 50,000 blocks
@rndazurescript
rndazurescript / CreateIso.ps1
Created June 4, 2020 01:06
Create ISO from powershell
function New-IsoFile
{
<# .Synopsis Creates a new .iso file .Description The New-IsoFile cmdlet creates a new .iso file containing content from chosen folders .Example New-IsoFile "c:\tools","c:Downloads\utils" This command creates a .iso file in $env:temp folder (default location) that contains c:\tools and c:\downloads\utils folders. The folders themselves are included at the root of the .iso image. .Example New-IsoFile -FromClipboard -Verbose Before running this command, select and copy (Ctrl-C) files/folders in Explorer first. .Example dir c:\WinPE | New-IsoFile -Path c:\temp\WinPE.iso -BootFile "${env:ProgramFiles(x86)}\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg\efisys.bin" -Media DVDPLUSR -Title "WinPE" This command creates a bootable .iso file containing the content from c:\WinPE folder, but the folder itself isn't included. Boot file etfsboot.com can be found in Windows ADK. Refer to IMAPI_MEDIA_PHYSICAL_TYPE enumeration for possible media types: http://msdn.micr
@rndazurescript
rndazurescript / ResetContainerLeaseState.py
Created May 2, 2020 12:48
Reset Lease state for an azure blob storage container that is in broken state
from azure.storage.common.cloudstorageaccount import CloudStorageAccount
# Retrieve the storage account and the storage key
import json
settings= {}
with open('./settings.json') as f:
settings = json.load(f)
account_name = settings["STORAGE_ACCOUNT_NAME"]
account_key = settings["STORAGE_ACCOUNT_KEY"]