Skip to content

Instantly share code, notes, and snippets.

@Gorgoras
Gorgoras / query-aas.ps1
Last active November 5, 2020 01:45
Query MDX to csv
$creds = Get-AutomationPSCredential -Name "ServPpalName"
# AAS Server to query
$server = "asazure://*.asazure.windows.net/*"
# Create xml object to parse response
[xml] $xmlDoc = New-Object system.Xml.XmlDocument
# Query definition
$AAS_db = "AAS_MODEL_NAME"
@Gorgoras
Gorgoras / checkIdleDatasets.py
Last active November 25, 2020 18:15
Check for Datasets not being used in any Pipeline in Azure Data Factory. Just clone the repo, then set repo_path, ADF name, and run!
import os
# set repo location and ADF name
repo_path = "D:/Work/Python/Azure"
dataFactory_name = "Highwayman-ADFv2"
full_path = "/".join([repo_path, dataFactory_name])
# get list of dataset and pipeline files
datasets = os.listdir("{}/dataset".format(full_path))
pipelines = os.listdir("{}/pipeline".format(full_path))
@Gorgoras
Gorgoras / ADF_Pipeline_Parameters.py
Created September 6, 2019 13:58
Call ADF pipeline with parameters, authenticating with a user or with a service principal.
from azure.mgmt.datafactory import DataFactoryManagementClient
from azure.common.credentials import UserPassCredentials #To login with user and pass, use this.
from azure.common.credentials import ServicePrincipalCredentials #To login with service principal (appid and client secret) use this
subscription_id = "subsID"
#Use only one of these, depending on how you want to login.
credentials = UserPassCredentials(username="user@yourdomain.com", password="yourpass") #To login with user and pass
credentials = ServicePrincipalCredentials(client_id='appid', secret='client secret', tenant='tenantid') #To login with serv ppal
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.datafactory import DataFactoryManagementClient as adf
from azure.mgmt.keyvault import KeyVaultManagementClient as keyvault
from azure.mgmt.storage import StorageManagementClient as blobacc
from azure.mgmt.datafactory.models import Factory as adf_model
from azure.mgmt.storage.models import StorageAccountCreateParameters as blob_model
from azure.mgmt.storage.models import (Sku, SkuName, Kind)
from azure.mgmt.sql import SqlManagementClient
import azure.mgmt.subscription as subs
import azure.common.credentials as cred