Skip to content

Instantly share code, notes, and snippets.

View DaveRuijter's full-sized avatar

Dave Ruijter DaveRuijter

View GitHub Profile
@DaveRuijter
DaveRuijter / vacuum_all_databricks_delta_tables.py
Created October 21, 2021 19:21
Script that iterates all tables in all databases that match the given database name filter, and performs the VACUUM command on each table.
database_names_filter = "20_silver*"
try:
dbs = spark.sql(f"SHOW DATABASES LIKE '{database_names_filter}'").select("databaseName").collect()
dbs = [(row.databaseName) for row in dbs]
for database_name in dbs:
print(f"Found database: {database_name}, performing actions on all its tables..")
tables = spark.sql(f"SHOW TABLES FROM `{database_name}`").select("tableName").collect()
tables = [(row.tableName) for row in tables]
for table_name in tables:
#spark.sql(f"ALTER TABLE `{database_name}`.`{table_name}` SET TBLPROPERTIES ('delta.logRetentionDuration'='interval 30 days', 'delta.deletedFileRetentionDuration'='interval 7 days')")
@DaveRuijter
DaveRuijter / gitversion.yml
Created October 3, 2021 20:27
My GitVersion configuration for automatic SemVer
next-version: 1.0
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatchTag
assembly-informational-format: '{InformationalVersion}'
mode: ContinuousDelivery
increment: Inherit
continuous-delivery-fallback-tag: ci
tag-prefix: '[vV]'
major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
@DaveRuijter
DaveRuijter / release-notes-template.md
Created October 3, 2021 20:23
Template file for automatic release notes

🚀 Release v{{buildDetails.buildNumber}}

Associated Pull Requests ({{pullRequests.length}})

{{#forEach pullRequests}}

  • Pull Request [#{{this.pullRequestId}} {{this.title}}]({{replace (replace this.url "_apis/git/repositories" "_git") "pullRequests" "pullRequest"}}) {{/forEach}}

Associated Azure Board Items ({{workItems.length}})

{{#forEach this.workItems}}

  • Item [#{{this.id}} {{lookup this.fields 'System.Title'}}]({{replace this.url "_apis/wit/workItems" "_workitems/edit"}})
@DaveRuijter
DaveRuijter / pipeline-release-administration.yml
Created October 3, 2021 19:47
Azure DevOps YAML pipeline for release administration, with automatic SemVer based on GitVersion and automatic release notes publication
trigger:
- main
- master
pool:
vmImage: ubuntu-latest
## Job to create release and add tag
jobs:
- job: CalculateVersion
@DaveRuijter
DaveRuijter / pipeline-pullrequest-administration.yml
Created October 3, 2021 19:13
Azure DevOps YAML pipeline for Pull Request administration, with SemVer based on the PR description
trigger:
- none
pool:
vmImage: ubuntu-latest
## Job to calculate semantic version
jobs:
- job: CalculateVersion
displayName: Semantic versioning
@DaveRuijter
DaveRuijter / pull_request_template.md
Created October 3, 2021 19:12
Azure DevOps Pull Request template with type of update

Type of update

  • Fix
  • Feature
  • Big feature
@DaveRuijter
DaveRuijter / RemoveServicePrincipalFromPowerBIWorkspaces.ps1
Created September 21, 2020 11:23
Script to remove Service Principal from Power BI workspaces
# =================================================================================================================================================
## This script will remove the given Service Principal from Power BI workspaces
## It will first ask for the (correct) ObjectId of the Service Principal
## Then it will ask for the credentials of a Power BI Service Administrator
# =================================================================================================================================================
## Parameters
# Remove the Service Principal from workspaces that are in Premium capacity?
$RemoveFromPremiumCapacityWorkspaces = $true
@DaveRuijter
DaveRuijter / AddServicePrincipalToPowerBIWorkspaces.ps1
Last active July 22, 2022 09:11
Script to add Service Principal to Power BI workspaces
# =================================================================================================================================================
## This script will add the given Service Principal to Power BI workspaces
## It will first ask for the (correct) ObjectId of the Service Principal
## Then it will ask for the credentials of a Power BI Service Administrator
## Note: this script only works with v2 workspaces (you can't add a Service Principal to a v1 workspace)
# =================================================================================================================================================
## Parameters
@DaveRuijter
DaveRuijter / pl_PBI_dataset_refresh.json
Last active November 28, 2022 19:23
Azure Data Factory pipeline to refresh a Power BI dataset using a Service Principal, and Azure Key Vault.
{
"name": "pipeline1",
"properties": {
"activities": [
{
"name": "Call dataset refresh",
"type": "WebActivity",
"dependsOn": [
{
"activity": "Get AAD Token",
@DaveRuijter
DaveRuijter / ADF_Scale_Azure_SQLDB.json
Created December 24, 2018 11:01
Azure Data Factory pipeline definition with a Web Activity to scale an Azure SQL Database. The pipeline is parameterized. The call to Azure SQL is synchronous, hence it waits for the db scale operation to complete.
{
"name": "ADF_Scale_Azure_SQLDB",
"properties": {
"activities": [
{
"name": "ADF_Scale_Azure_SQLDB",
"type": "WebActivity",
"policy": {
"timeout": "7.00:00:00",
"retry": 0,