<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PowerShell Archives - AzureOps</title>
	<atom:link href="https://azureops.org/articles/category/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>https://azureops.org/articles/category/powershell/</link>
	<description>Notable things about Cloud, Data and DevOps.</description>
	<lastBuildDate>Sun, 11 Jan 2026 18:31:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i0.wp.com/azureops.org/wp-content/uploads/2021/04/cropped-android-chrome-512x512-1.png?fit=32%2C32&#038;ssl=1</url>
	<title>PowerShell Archives - AzureOps</title>
	<link>https://azureops.org/articles/category/powershell/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">190208641</site>	<item>
		<title>Compare Azure SQL Database Schema Using sqlpackage</title>
		<link>https://azureops.org/articles/compare-azure-sql-database-schema-using-sqlpackage/</link>
		
		<dc:creator><![CDATA[Kunal Rathi]]></dc:creator>
		<pubDate>Sat, 10 Jan 2026 19:16:23 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SQL Database]]></category>
		<category><![CDATA[SQL Server]]></category>
		<guid isPermaLink="false">https://azureops.org/?p=9188</guid>

					<description><![CDATA[<p>Learn how to compare two Azure SQL Database Schema effectively and generate delta scripts for seamless deployment.</p>
<p>The post <a href="https://azureops.org/articles/compare-azure-sql-database-schema-using-sqlpackage/">Compare Azure SQL Database Schema Using sqlpackage</a> appeared first on <a href="https://azureops.org">AzureOps</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="">When working with Azure SQL Databases, it is quite common to have multiple environments such as <strong>Dev</strong>, <strong>Test</strong>, <strong>UAT</strong>, and <strong>Production</strong>. Over time, schema drift between these environments becomes inevitable. Before deploying changes to production, it is critical to understand <em>exactly</em> what is different and what will change.</p>



<p class="">In this article, we will see how to <strong>compare Azure SQL database schema using <code>sqlpackage.exe</code></strong> and generate a <strong>delta script</strong> that shows the differences in a controlled and repeatable way. The approach and flow are similar to the DACPAC-based comparison strategy discussed earlier on AzureOps.</p>



<h2 class="wp-block-heading">Why use sqlpackage for database comparison?</h2>



<p class=""><code><a href="https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage?view=sql-server-ver17" target="_blank" rel="noreferrer noopener">sqlpackage.exe</a></code> is a command-line utility provided by Microsoft that works with <strong>DACPAC</strong> and <strong>BACPAC</strong> files. Using <code>sqlpackage</code>, you can:</p>



<ul class="wp-block-list">
<li class="">Compare two databases using DACPACs</li>



<li class="">Generate a deployment (delta) script</li>



<li class="">Control destructive changes explicitly</li>



<li class="">Automate comparisons in CI/CD pipelines</li>
</ul>



<p class="">For Azure SQL Database scenarios, this method is especially useful when direct schema comparison tools are not available or when automation is required.</p>



<h2 class="wp-block-heading">Creating a DACPAC</h2>



<p class="">To compare database schemas using <code>sqlpackage</code>, you first need a <strong>DACPAC</strong> file, which represents the database schema.</p>



<p class="">You can create a DACPAC using <strong>sqlpackage.exe</strong>, <strong>SSMS</strong>, or <strong>Visual Studio</strong>. For a quick, step-by-step guide covering all methods, refer to this <a href="https://azureops.org/articles/dacpac-sql-server-database/?utm_source=chatgpt.com" target="_blank" rel="noreferrer noopener">article</a>.</p>



<h2 class="wp-block-heading">Installing <code>sqlpackage</code> Before You Begin</h2>



<p class="">Before you can compare two Azure SQL database schemas using <code>sqlpackage</code>, you need to <strong>install the <code>sqlpackage</code> command-line utility</strong> on your machine. <code>sqlpackage.exe</code> is the same tool that Powers the DACPAC deployments discussed in this site’s previous article on deploying DACPACs to Azure SQL Database.</p>



<p class="">Here are the recommended ways to install <code>sqlpackage</code>, depending on your environment:</p>



<h3 class="wp-block-heading">Option 1 — Install as a .NET Global Tool (Cross-Platform)</h3>



<p class="">The easiest and most modern way to install <code>sqlpackage</code> on <strong>Windows, macOS, or Linux</strong> is using the <strong>.NET SDK tool installer</strong>. This gives you the <code>sqlpackage</code> command directly on your PATH. Run below command in command prompt.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; gutter: false; title: ; notranslate">
dotnet tool install --global Microsoft.SqlPackage
</pre></div>


<p class="">If you already have it installed and want to update to the latest version, run:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; gutter: false; title: ; notranslate">
dotnet tool update --global Microsoft.SqlPackage
</pre></div>


<p class="">This method works well for local development and automation scripts, including PowerShell and CI/CD pipelines.</p>



<h3 class="wp-block-heading">Option 2 — Download Standalone Zip (Windows / macOS / Linux)</h3>



<p class="">If you don’t use the .NET SDK or prefer a <strong>self-contained download</strong>, Microsoft also publishes standalone builds of <code>sqlpackage</code>:</p>



<ol class="wp-block-list">
<li class="">Visit the official SqlPackage<a href="https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-download?view=sql-server-ver17" target="_blank" rel="noreferrer noopener"> download page</a> on Microsoft Docs.</li>



<li class="">Download the appropriate zip for your OS.</li>



<li class="">Extract and place the folder somewhere on your system (e.g., <code>C:\tools\sqlpackage</code>).</li>



<li class="">Add the folder containing <code>sqlpackage.exe</code> to your system PATH so you can call it from any terminal.</li>
</ol>



<p class="">This method is useful if you want to avoid installing .NET tools or need to bundle <code>sqlpackage</code> with deployment scripts.</p>



<figure class="wp-block-image size-full is-resized"><a href="https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/image.png?ssl=1"><img fetchpriority="high" decoding="async" width="1090" height="420" data-attachment-id="9206" data-permalink="https://azureops.org/articles/compare-azure-sql-database-schema-using-sqlpackage/image-46/" data-orig-file="https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/image.png?fit=1090%2C420&amp;ssl=1" data-orig-size="1090,420" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="image" data-image-description="" data-image-caption="" data-large-file="https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/image.png?fit=1090%2C420&amp;ssl=1" src="https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/image.png?fit=1090%2C420&amp;ssl=1" alt="compare Azure SQL Database Schema" class="wp-image-9206" style="width:809px;height:auto" srcset="https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/image.png?w=1090&amp;ssl=1 1090w, https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/image.png?resize=300%2C116&amp;ssl=1 300w, https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/image.png?resize=768%2C296&amp;ssl=1 768w, https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/image.png?resize=450%2C173&amp;ssl=1 450w, https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/image.png?resize=600%2C231&amp;ssl=1 600w" sizes="(max-width: 1090px) 100vw, 1090px" /></a></figure>



<h2 class="wp-block-heading">High-level approach</h2>



<p class="">The comparison process consists of three simple steps:</p>



<ol class="wp-block-list">
<li class="">Export both Azure SQL databases to DACPAC files</li>



<li class="">Use <code>sqlpackage.exe</code> with <code>/Action:Script</code></li>



<li class="">Review the generated delta script before applying it</li>
</ol>



<p class="">In this article, we focus on <strong>step 2</strong>, assuming you already have DACPAC files for both databases.</p>



<h2 class="wp-block-heading">Sample scenario</h2>



<p class="">Let us assume the following setup:</p>



<ul class="wp-block-list">
<li class=""><strong>Source (baseline)</strong> database: <code>sales-test-db</code></li>



<li class=""><strong>Target (to be aligned)</strong> database: <code>sales-prod-db</code></li>
</ul>



<p class="">Our goal is to compare Azure SQL Database schema and generate a SQL script that shows what changes are required to make <strong>Production</strong> match <strong>Test</strong>.</p>



<h2 class="wp-block-heading">Sample sqlpackage command</h2>



<p class="">Below is a sample <code>sqlpackage.exe</code> command to compare two DACPAC files and generate a delta script.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
sqlpackage.exe ^
  /Action:Script ^
  /SourceFile:&quot;C:\Dacpacs\sales-test-db.dacpac&quot; ^
  /TargetFile:&quot;C:\Dacpacs\sales-prod-db.dacpac&quot; ^
  /TargetDatabaseName:&quot;sales-prod-db&quot; ^
  /OutputPath:&quot;C:\Dacpacs\sales_test_vs_prod_delta.sql&quot; ^
  /p:DropObjectsNotInSource=True

</pre></div>


<figure class="wp-block-image size-full is-resized"><a href="https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/sqlpackage-to-compare-azure-sql-database-schema.png?ssl=1"><img decoding="async" width="1153" height="221" data-attachment-id="9192" data-permalink="https://azureops.org/articles/compare-azure-sql-database-schema-using-sqlpackage/sqlpackage-to-compare-azure-sql-database-schema/" data-orig-file="https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/sqlpackage-to-compare-azure-sql-database-schema.png?fit=1153%2C221&amp;ssl=1" data-orig-size="1153,221" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="sqlpackage to compare azure sql database schema" data-image-description="" data-image-caption="" data-large-file="https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/sqlpackage-to-compare-azure-sql-database-schema.png?fit=1153%2C221&amp;ssl=1" src="https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/sqlpackage-to-compare-azure-sql-database-schema.png?fit=1153%2C221&amp;ssl=1" alt="compare Azure SQL Database Schema using sqlpackage utility" class="wp-image-9192" style="aspect-ratio:5.217492752598458;width:881px;height:auto" srcset="https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/sqlpackage-to-compare-azure-sql-database-schema.png?w=1153&amp;ssl=1 1153w, https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/sqlpackage-to-compare-azure-sql-database-schema.png?resize=300%2C58&amp;ssl=1 300w, https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/sqlpackage-to-compare-azure-sql-database-schema.png?resize=768%2C147&amp;ssl=1 768w, https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/sqlpackage-to-compare-azure-sql-database-schema.png?resize=450%2C86&amp;ssl=1 450w, https://i0.wp.com/azureops.org/wp-content/uploads/2026/01/sqlpackage-to-compare-azure-sql-database-schema.png?resize=600%2C115&amp;ssl=1 600w" sizes="(max-width: 1153px) 100vw, 1153px" /></a></figure>



<p class="">In case you want to use PowerShell ISE, you can use below script.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: powershell; title: ; notranslate">
# Path to sqlpackage.exe
$sqlPackagePath = &quot;C:\Program Files\Microsoft SQL Server\160\DAC\bin\sqlpackage.exe&quot;

# DACPAC paths
$SourceDacpacPath = &quot;C:\Dacpacs\sales-test-db.dacpac&quot;
$TargetDacpacPath = &quot;C:\Dacpacs\sales-prod-db.dacpac&quot;

# Target database name
$TargetDatabaseName = &quot;sales-prod-db&quot;

# Output script path
$OutputScriptPath = &quot;C:\Dacpacs\sales_test_vs_prod_delta.sql&quot;

# Publish options
$DropObjectsNotInSource = &quot;True&quot;

# Execute sqlpackage
&amp; $sqlPackagePath `
    /Action:Script `
    /SourceFile:$SourceDacpacPath `
    /TargetFile:$TargetDacpacPath `
    /TargetDatabaseName:$TargetDatabaseName `
    /OutputPath:$OutputScriptPath `
    /p:DropObjectsNotInSource=$DropObjectsNotInSource

</pre></div>


<p class="">This command does <strong>not</strong> apply any changes. It only generates a SQL script that you can review and execute manually if needed.</p>



<h2 class="wp-block-heading">Understanding each parameter</h2>



<p class="">Let us break down all the parameters used in the command.</p>



<p class=""><strong>/Action:Script</strong></p>



<p class="">Specifies that <code>sqlpackage</code> should <strong>generate a deployment script</strong> instead of publishing changes directly to a database. This is the safest option when comparing environments like Test and Production.</p>



<p class=""><strong>/SourceFile</strong></p>



<p class="">Path to the <strong>source DACPAC</strong> file. This represents the <em>desired state</em> of the database.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; gutter: false; title: ; notranslate">
/SourceFile:&quot;C:\Dacpacs\sales-test-db.dacpac&quot;
</pre></div>


<p class="">In our example, the Test database schema is treated as the source of truth.</p>



<p class=""><strong>/TargetFile</strong></p>



<p class="">Path to the <strong>target DACPAC</strong> file. This represents the database you want to compare against.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; gutter: false; title: ; notranslate">
/TargetFile:&quot;C:\Dacpacs\sales-prod-db.dacpac&quot;
</pre></div>


<p class="">The generated script will contain changes required to make the target match the source.</p>



<p class=""><strong>/TargetDatabaseName</strong></p>



<p class="">Logical name of the target database.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; gutter: false; title: ; notranslate">
/TargetDatabaseName:&quot;sales-prod-db&quot;
</pre></div>


<p class="">This parameter is mandatory for the <code>Script</code> action, even when you are comparing DACPAC-to-DACPAC.</p>



<p class=""><strong>/OutputPath</strong></p>



<p class="">Specifies where the generated delta script should be written.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; gutter: false; title: ; notranslate">
/OutputPath:&quot;C:\Dacpacs\sales_test_vs_prod_delta.sql&quot;
</pre></div>


<p class="">Always review this script carefully before executing it in Production.</p>



<p class=""><strong>/p:DropObjectsNotInSource</strong></p>



<p class="">Controls whether objects that exist in the target but not in the source should be dropped.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; gutter: false; title: ; notranslate">
/p:DropObjectsNotInSource=True
</pre></div>


<ul class="wp-block-list">
<li class=""><code>True</code> – Generates <code>DROP</code> statements for extra objects in the target</li>



<li class=""><code>False</code> – Preserves objects that exist only in the target</li>
</ul>



<p class="">⚠️ <strong>Use this option with caution</strong>, especially for Production databases.</p>



<h2 class="wp-block-heading">Common additional publish parameters</h2>



<p class="">Depending on your requirements, you may also consider these commonly used parameters:</p>



<ul class="wp-block-list">
<li class=""><code>/p:BlockOnPossibleDataLoss=False</code></li>



<li class=""><code>/p:IgnorePermissions=True</code></li>



<li class=""><code>/p:IgnoreRoleMembership=True</code></li>



<li class=""><code>/p:ExcludeObjectTypes=Users;Logins</code></li>



<li class=""><code>/p:ExcludeSchemaValidation=True</code></li>
</ul>



<p class="">These options help fine-tune the comparison and avoid unwanted differences.</p>



<h2 class="wp-block-heading">Best practices</h2>



<ul class="wp-block-list">
<li class="">Always generate a script first (<code>/Action:Script</code>)</li>



<li class="">Review the delta script line by line</li>



<li class="">Never auto-apply changes to Production without validation</li>



<li class="">Store DACPACs and scripts in source control</li>



<li class="">Use the same approach in CI/CD pipelines for consistency</li>
</ul>



<h2 class="wp-block-heading">Conclusion</h2>



<p class="">Comparing two Azure SQL databases using <code>sqlpackage.exe</code> is a reliable and automation-friendly approach. By working with DACPAC files and generating delta scripts, you gain full visibility and control over schema changes before they reach Production.</p>



<p class="">This method fits well into modern DevOps workflows and provides a safe alternative to manual or GUI-based comparisons.</p>



<p class="">If you regularly manage schema changes across multiple environments, <code>sqlpackage</code> should be a core part of your database deployment tool.</p>



<p class="has-light-green-cyan-background-color has-background"><strong>Pro tips</strong><br>1. If you want to generate BACPAC file of an Azure SQL database, you can refer to this <a href="https://azureops.org/articles/bacpac-large-sql-server-database/" target="_blank" rel="noreferrer noopener">post</a></p>



<h2 class="wp-block-heading">See more</h2>



<iframe width="700" height="394" src="https://www.youtube.com/embed/8YVrxCgdiIg" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
<p>The post <a href="https://azureops.org/articles/compare-azure-sql-database-schema-using-sqlpackage/">Compare Azure SQL Database Schema Using sqlpackage</a> appeared first on <a href="https://azureops.org">AzureOps</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">9188</post-id>	</item>
		<item>
		<title>Programmatically Start and Stop Azure Data Factory Integration Runtime</title>
		<link>https://azureops.org/articles/data-factory-automation-with-managed-identity/</link>
		
		<dc:creator><![CDATA[Kunal Rathi]]></dc:creator>
		<pubDate>Thu, 08 Feb 2024 20:43:56 +0000</pubDate>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[Data Factory]]></category>
		<category><![CDATA[PowerShell]]></category>
		<guid isPermaLink="false">https://azureops.org/?p=7131</guid>

					<description><![CDATA[<p> This article describes how to perform Azure Data Factory automation with managed identity and Azure automation account.</p>
<p>The post <a href="https://azureops.org/articles/data-factory-automation-with-managed-identity/">Programmatically Start and Stop Azure Data Factory Integration Runtime</a> appeared first on <a href="https://azureops.org">AzureOps</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="">Azure Data Factory is a Microsoft cloud ETL service for serverless data integrations and orchestrations. <a href="https://learn.microsoft.com/en-us/azure/automation/overview" target="_blank" rel="noreferrer noopener">Azure automation account</a> is a service by Microsoft to automate various management activities in Azure cloud. You can leverage an automation account if you want to start and stop Azure Data Factory SSIS runtime programmatically. This article describes how to programmatically start and stop Azure Data Factory integration runtime using managed identity and Azure automation account.</p>



<p class="has-pale-cyan-blue-background-color has-background"><strong>Pre-requisites</strong>:<br>To implement Azure Data Factory automation using Azure automation account you would need,<br>1. Azure subscription and a resource group with Azure Data Factory and Azure Automation Account.<br>2. Admin permission to grant access to Azure automation account on Azure Data Factory.</p>



<h2 class="wp-block-heading">What is Managed Identity?</h2>



<p class=""><a href="https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview" target="_blank" rel="noreferrer noopener">Managed identity&nbsp;</a>is a&nbsp;<a href="https://learn.microsoft.com/en-us/azure/active-directory/develop/app-objects-and-service-principals" target="_blank" rel="noreferrer noopener">service principal</a>&nbsp;associated with resources in Azure. When we create a Data Factory in Azure, it automatically creates an app in Microsoft Entra ID (Azure active directory).To connect Azure Data Factory from Azure automation account, we need to grant Azure automation account&#8217;s system-assigned managed identity access to the Azure Data Factory. This makes access management more secure and easy.</p>



<h3 class="wp-block-heading">Benefits of using managed identity authentication</h3>



<p class="">1. You don’t need to manage credentials.<br>2. You can use managed identities to authenticate to any resource that supports Entra ID authentication, including your applications.<br>3. Managed identities can be used at no extra cost.</p>



<h3 class="wp-block-heading">Types of managed identities</h3>



<p class="">There are two types of managed identities:<br>1. System assigned managed identity – This is the identity that is associated with Azure resources like Azure automation account.<br>2. User-assigned managed identity – This identity is created and managed by the user in Azure portal. Learn more about it&nbsp;<a href="https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities?pivots=identity-mi-methods-azp" target="_blank" rel="noreferrer noopener">here</a>.</p>



<p class="">Let us now see how the system-assigned managed identity of Azure automation account can be used to connect and manage Azure Data Factory integration runtime.</p>



<h2 class="wp-block-heading">Enable the System assigned managed identity for Azure automation account</h2>



<p class="">1. Navigate to Azure automation account resource in Azure <a href="https://portal.azure.com/">portal</a>. </p>



<p class="">2. Click &#8216;Identity&#8217; under &#8216;Account Settings&#8217; as shown in the image below. </p>



<p class="">3. Under the System assigned tab, enable Status and click Save.</p>



<figure class="wp-block-image size-large is-resized"><a href="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Enable-managed-identity-in-Azure-automation-account.png?ssl=1"><img data-recalc-dims="1" decoding="async" width="1200" height="625" data-attachment-id="7134" data-permalink="https://azureops.org/articles/data-factory-automation-with-managed-identity/enable-managed-identity-in-azure-automation-account/" data-orig-file="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Enable-managed-identity-in-Azure-automation-account.png?fit=1303%2C679&amp;ssl=1" data-orig-size="1303,679" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Enable-managed-identity-in-Azure-automation-account" data-image-description="" data-image-caption="" data-large-file="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Enable-managed-identity-in-Azure-automation-account.png?fit=1200%2C625&amp;ssl=1" src="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Enable-managed-identity-in-Azure-automation-account.png?resize=1200%2C625&#038;ssl=1" alt="Enable managed identity of Azure automation account." class="wp-image-7134" style="width:936px;height:auto" srcset="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Enable-managed-identity-in-Azure-automation-account.png?resize=1200%2C625&amp;ssl=1 1200w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Enable-managed-identity-in-Azure-automation-account.png?resize=300%2C156&amp;ssl=1 300w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Enable-managed-identity-in-Azure-automation-account.png?resize=1190%2C620&amp;ssl=1 1190w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Enable-managed-identity-in-Azure-automation-account.png?resize=768%2C400&amp;ssl=1 768w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Enable-managed-identity-in-Azure-automation-account.png?resize=450%2C234&amp;ssl=1 450w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Enable-managed-identity-in-Azure-automation-account.png?resize=600%2C313&amp;ssl=1 600w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Enable-managed-identity-in-Azure-automation-account.png?w=1303&amp;ssl=1 1303w" sizes="(max-width: 1200px) 100vw, 1200px" /></a></figure>



<figure class="is-style-default wp-block-image size-large is-resized"><a href="https://marketplace.visualstudio.com/items?itemName=AzureOps.ssiscatalogerpro&amp;ssr=false#overview" target="_blank" rel="noopener"><img data-recalc-dims="1" loading="lazy" decoding="async" width="1200" height="148" data-attachment-id="4839" data-permalink="https://azureops.org/articles/azure-data-studio-for-sql-developers/scmw-horizontal-ad/" data-orig-file="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?fit=1326%2C163&amp;ssl=1" data-orig-size="1326,163" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="SCMW-horizontal-ad" data-image-description="" data-image-caption="" data-large-file="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?fit=1200%2C148&amp;ssl=1" src="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=1200%2C148&#038;ssl=1" alt="" class="wp-image-4839" style="object-fit:cover;width:811px;height:99px" srcset="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=1200%2C148&amp;ssl=1 1200w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=450%2C55&amp;ssl=1 450w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=600%2C74&amp;ssl=1 600w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=300%2C37&amp;ssl=1 300w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=768%2C94&amp;ssl=1 768w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?w=1326&amp;ssl=1 1326w" sizes="(max-width: 1200px) 100vw, 1200px" /></a></figure>



<h2 class="wp-block-heading">Grant access to Azure automation account on Azure Data Factory </h2>



<p class="">1. Navigate to Data Factory resource in Azure portal and Click on Access control (IAM).  Click Add -&gt; Add role assignment as shown in the image below.</p>



<figure class="wp-block-image size-large is-resized"><a href="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Add-IAM-of-Azure-data-factory.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" width="1200" height="366" data-attachment-id="7156" data-permalink="https://azureops.org/articles/data-factory-automation-with-managed-identity/add-iam-of-azure-data-factory/" data-orig-file="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Add-IAM-of-Azure-data-factory.png?fit=1256%2C383&amp;ssl=1" data-orig-size="1256,383" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Add-IAM-of-Azure-data-factory" data-image-description="" data-image-caption="" data-large-file="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Add-IAM-of-Azure-data-factory.png?fit=1200%2C366&amp;ssl=1" src="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Add-IAM-of-Azure-data-factory.png?resize=1200%2C366&#038;ssl=1" alt="programmatically start and stop Azure Data Factory integration runtime " class="wp-image-7156" style="width:992px;height:auto" srcset="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Add-IAM-of-Azure-data-factory.png?resize=1200%2C366&amp;ssl=1 1200w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Add-IAM-of-Azure-data-factory.png?resize=300%2C91&amp;ssl=1 300w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Add-IAM-of-Azure-data-factory.png?resize=768%2C234&amp;ssl=1 768w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Add-IAM-of-Azure-data-factory.png?resize=450%2C137&amp;ssl=1 450w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Add-IAM-of-Azure-data-factory.png?resize=600%2C183&amp;ssl=1 600w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Add-IAM-of-Azure-data-factory.png?w=1256&amp;ssl=1 1256w" sizes="(max-width: 1200px) 100vw, 1200px" /></a></figure>



<p class="">2. Grant sufficient role to Azure automation account resource on Data Factory resource under the Role tab. Job function role &#8211; &#8216;Data Factory Contributor&#8217; should be sufficient to perform management activities on Data Factory.</p>



<figure class="wp-block-image size-full"><a href="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Select-role-in-Azure-data-factory-IAM.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" width="924" height="453" data-attachment-id="7157" data-permalink="https://azureops.org/articles/data-factory-automation-with-managed-identity/select-role-in-azure-data-factory-iam/" data-orig-file="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Select-role-in-Azure-data-factory-IAM.png?fit=924%2C453&amp;ssl=1" data-orig-size="924,453" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Select-role-in-Azure-data-factory-IAM" data-image-description="" data-image-caption="" data-large-file="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Select-role-in-Azure-data-factory-IAM.png?fit=924%2C453&amp;ssl=1" src="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Select-role-in-Azure-data-factory-IAM.png?resize=924%2C453&#038;ssl=1" alt="" class="wp-image-7157" srcset="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Select-role-in-Azure-data-factory-IAM.png?w=924&amp;ssl=1 924w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Select-role-in-Azure-data-factory-IAM.png?resize=300%2C147&amp;ssl=1 300w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Select-role-in-Azure-data-factory-IAM.png?resize=768%2C377&amp;ssl=1 768w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Select-role-in-Azure-data-factory-IAM.png?resize=450%2C221&amp;ssl=1 450w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Select-role-in-Azure-data-factory-IAM.png?resize=600%2C294&amp;ssl=1 600w" sizes="(max-width: 924px) 100vw, 924px" /></a></figure>



<p class="">3. Under the Members tab, select &#8216;Managed Identity&#8217;. Search for the managed identity of Azure automation account to whom you want to grant access.</p>



<figure class="wp-block-image size-large is-resized"><a href="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Grant-access-to-Azure-automation-account-on-Azure-data-factory-1.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" width="1200" height="451" data-attachment-id="7155" data-permalink="https://azureops.org/articles/data-factory-automation-with-managed-identity/grant-access-to-azure-automation-account-on-azure-data-factory-1/" data-orig-file="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Grant-access-to-Azure-automation-account-on-Azure-data-factory-1.png?fit=1864%2C701&amp;ssl=1" data-orig-size="1864,701" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Grant-access-to-Azure-automation-account-on-Azure-data-factory-1" data-image-description="" data-image-caption="" data-large-file="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Grant-access-to-Azure-automation-account-on-Azure-data-factory-1.png?fit=1200%2C451&amp;ssl=1" src="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Grant-access-to-Azure-automation-account-on-Azure-data-factory-1.png?resize=1200%2C451&#038;ssl=1" alt="programmatically start and stop Azure Data Factory integration runtime " class="wp-image-7155" style="width:1074px;height:auto" srcset="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Grant-access-to-Azure-automation-account-on-Azure-data-factory-1.png?resize=1200%2C451&amp;ssl=1 1200w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Grant-access-to-Azure-automation-account-on-Azure-data-factory-1.png?resize=300%2C113&amp;ssl=1 300w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Grant-access-to-Azure-automation-account-on-Azure-data-factory-1.png?resize=768%2C289&amp;ssl=1 768w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Grant-access-to-Azure-automation-account-on-Azure-data-factory-1.png?resize=1536%2C578&amp;ssl=1 1536w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Grant-access-to-Azure-automation-account-on-Azure-data-factory-1.png?resize=450%2C169&amp;ssl=1 450w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Grant-access-to-Azure-automation-account-on-Azure-data-factory-1.png?resize=600%2C226&amp;ssl=1 600w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Grant-access-to-Azure-automation-account-on-Azure-data-factory-1.png?w=1864&amp;ssl=1 1864w" sizes="(max-width: 1200px) 100vw, 1200px" /></a></figure>



<h2 class="wp-block-heading">Start And Stop Azure Data Factory IR using PowerShell runbook</h2>



<p class="">1.  Import Azure Az PowerShell modules in automation account. Under the automation account resource, navigate to &#8216;Shared resources&#8217; -> &#8216;Modules&#8217;.</p>



<p class="">2. Create &#8216;datafactory-name&#8217; and &#8216;resourcegroup-name&#8217; variables in the automation account and assign appropriate values to them.</p>



<figure class="wp-block-image size-large"><a href="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Create-variables-in-Azure-automation-account.png?ssl=1"><img data-recalc-dims="1" loading="lazy" decoding="async" width="1200" height="362" data-attachment-id="8102" data-permalink="https://azureops.org/articles/data-factory-automation-with-managed-identity/create-variables-in-azure-automation-account/" data-orig-file="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Create-variables-in-Azure-automation-account.png?fit=1374%2C415&amp;ssl=1" data-orig-size="1374,415" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Create variables in Azure automation account" data-image-description="" data-image-caption="" data-large-file="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Create-variables-in-Azure-automation-account.png?fit=1200%2C362&amp;ssl=1" src="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Create-variables-in-Azure-automation-account.png?resize=1200%2C362&#038;ssl=1" alt="" class="wp-image-8102" srcset="https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Create-variables-in-Azure-automation-account.png?resize=1200%2C362&amp;ssl=1 1200w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Create-variables-in-Azure-automation-account.png?resize=300%2C91&amp;ssl=1 300w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Create-variables-in-Azure-automation-account.png?resize=768%2C232&amp;ssl=1 768w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Create-variables-in-Azure-automation-account.png?resize=450%2C136&amp;ssl=1 450w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Create-variables-in-Azure-automation-account.png?resize=600%2C181&amp;ssl=1 600w, https://i0.wp.com/azureops.org/wp-content/uploads/2024/02/Create-variables-in-Azure-automation-account.png?w=1374&amp;ssl=1 1374w" sizes="(max-width: 1200px) 100vw, 1200px" /></a></figure>



<p class="">3. Navigate to &#8216;Process Automation&#8217; left side section under Azure automation account and click &#8216;Runbooks&#8217; . Create a new PowerShell runbook and provide necessary details.</p>



<p class="">4. You can use the code below to connect and stop/start Integration runtime in Azure Data Factory.</p>



<h4 class="wp-block-heading">Stop ADF integration runtime</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: powershell; title: ; notranslate">
# Retrieve Automation Variables
$DataFactoryName = Get-AzAutomationVariable -Name &#039;datafactory-name&#039;
$ResourceGroup = Get-AzAutomationVariable -Name &#039;resourcegroup-name&#039;

# Authenticate to Azure
Connect-AzAccount

# Get Integration Runtime in Azure Data Factory
$IntegrationRuntime = Get-AzDataFactoryV2IntegrationRuntime `
                            -DataFactoryName $DataFactoryName `
                            -ResourceGroupName $ResourceGroup

# Check the current status of the Integration Runtime
$IRStatus = $IntegrationRuntime.Status
Write-Output &quot;Current Integration Runtime Status: $IRStatus&quot;

# Stop the Integration Runtime if it is running
if ($IRStatus -eq &#039;Online&#039;) {
    Stop-AzDataFactoryV2IntegrationRuntime `
        -DataFactoryName $DataFactoryName `
        -ResourceGroupName $ResourceGroup `
        -Name $IntegrationRuntime.Name

    Write-Output &quot;Integration Runtime &#039;$($IntegrationRuntime.Name)&#039; has been stopped.&quot;
} else {
    Write-Output &quot;Integration Runtime &#039;$($IntegrationRuntime.Name)&#039; is already stopped or in a state that cannot be stopped.&quot;
}

</pre></div>


<h4 class="wp-block-heading">Start ADF integration runtime</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: powershell; title: ; notranslate">
# Retrieve Automation Variables
$DataFactoryName = Get-AzAutomationVariable -Name &#039;datafactory-name&#039;
$ResourceGroup = Get-AzAutomationVariable -Name &#039;resourcegroup-name&#039;

# Authenticate to Azure
Connect-AzAccount

# Get Integration Runtime in Azure Data Factory
$IntegrationRuntime = Get-AzDataFactoryV2IntegrationRuntime `
                            -DataFactoryName $DataFactoryName `
                            -ResourceGroupName $ResourceGroup

# Check the current status of the Integration Runtime
$IRStatus = $IntegrationRuntime.Status
Write-Output &quot;Current Integration Runtime Status: $IRStatus&quot;

# Start the Integration Runtime if it is not running
if ($IRStatus -ne &#039;Online&#039;) {
    Start-AzDataFactoryV2IntegrationRuntime `
        -DataFactoryName $DataFactoryName `
        -ResourceGroupName $ResourceGroup `
        -Name $IntegrationRuntime.Name

    Write-Output &quot;Integration Runtime &#039;$($IntegrationRuntime.Name)&#039; is starting.&quot;
} else {
    Write-Output &quot;Integration Runtime &#039;$($IntegrationRuntime.Name)&#039; is already running.&quot;
}

</pre></div>


<p class="">Notice in the above code blocks that we have not used any credentials to authenticate to Azure. This is because authentication is taken care of using managed identity. </p>



<p class="has-background" style="background-color:#bcefca"><strong>Pro tips:</strong><br>1. <a href="https://azureops.org/articles/connect-azure-sql-from-data-factory-using-managed-identity/" target="_blank" rel="noreferrer noopener">Learn </a>how to connect to Azure SQL from Azure Data Factory using managed identity.<br>2. Azure Automation Run as accounts, including Classic Run as accounts have retired on&nbsp;30 September 2023. It is now mandatory to use the managed identity.</p>



<h2 class="wp-block-heading">See more</h2>



<iframe width="700" height="394" src="https://www.youtube.com/embed/t2h6xNVFQkc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="is-style-fill wp-block-button"><a class="wp-block-button__link has-white-color has-blush-light-purple-gradient-background has-text-color has-background has-link-color wp-element-button" href="https://azureops.org/product/ssis-catalog-migration-wizard-pro/" target="_blank" rel="noreferrer noopener">Download Now</a></div>
</div>



<p class="">&nbsp;&nbsp;&nbsp;&nbsp;</p>



<p class=""></p>
<p>The post <a href="https://azureops.org/articles/data-factory-automation-with-managed-identity/">Programmatically Start and Stop Azure Data Factory Integration Runtime</a> appeared first on <a href="https://azureops.org">AzureOps</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">7131</post-id>	</item>
		<item>
		<title>Disable and Enable triggers in Azure Data Factory using PowerShell</title>
		<link>https://azureops.org/articles/disable-and-enable-triggers-in-azure-data-factory/</link>
		
		<dc:creator><![CDATA[Kunal Rathi]]></dc:creator>
		<pubDate>Mon, 31 Jul 2023 19:59:29 +0000</pubDate>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[Data Factory]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[azure data factory ci/cd]]></category>
		<category><![CDATA[azure data factory triggers]]></category>
		<guid isPermaLink="false">https://azureops.org/?p=6310</guid>

					<description><![CDATA[<p>This article will provide step-by-step instructions to enable and disable triggers in Azure Data Factory using PowerShell.</p>
<p>The post <a href="https://azureops.org/articles/disable-and-enable-triggers-in-azure-data-factory/">Disable and Enable triggers in Azure Data Factory using PowerShell</a> appeared first on <a href="https://azureops.org">AzureOps</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="">Companies depend on efficient data processing and management systems to make informed decisions in the fast-moving business world. <a href="https://learn.microsoft.com/en-us/azure/data-factory/introduction" target="_blank" rel="noreferrer noopener">Azure Data Factory</a> (ADF) is a highly effective cloud-based data integration service that allows organizations to orchestrate and automate data workflows easily. One of the critical features of ADF is the ability to activate and deactivate triggers, which are essential for controlling the execution of data pipelines and factory maintenance. This article will provide step-by-step instructions to enable and disable triggers in Azure Data Factory.</p>



<p class="has-pale-cyan-blue-background-color has-background"><strong>Pre-requisites:</strong><br>1. Access to Data Factory resources in the Azure portal.<br>2. Az PowerShell&nbsp;<a href="https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-7.1.0" target="_blank" rel="noreferrer noopener">module</a>&nbsp;installed on the local machine.</p>



<h2 class="wp-block-heading">Understanding Azure Data Factory Triggers</h2>



<p class="">Azure Data Factory utilizes triggers to initiate data pipeline executions based on specific conditions automatically. These conditions can be set on a schedule, event, or through manual intervention. Triggers play a crucial role in ensuring that data pipelines run at the correct time, keeping data processing up-to-date and accurate. Turning triggers on-demand on and off gives data engineers the flexibility to control the data flow efficiently.</p>



<h2 class="wp-block-heading">Script to disable and enable triggers in Azure Data Factory</h2>



<p class="">Use the below PowerShell script to disable all the triggers in Azure Data Factory.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: powershell; gutter: false; title: ; notranslate">
$adf_name = &#039;adfname&#039;
$resourcegroup_name = &#039;resourcegroupname&#039;

$triggersADF = Get-AzDataFactoryV2Trigger -DataFactoryName $adf_name -ResourceGroupName $resourcegroup_name; 
$triggersADF | ForEach-Object { Stop-AzDataFactoryV2Trigger -ResourceGroupName $resourcegroup_name -DataFactoryName $adf_name -Name $_.name -Force }
</pre></div>


<p class="">Use the below PowerShell script to enable all the triggers in Azure Data Factory.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: powershell; gutter: false; title: ; notranslate">
$adf_name = &#039;adfname&#039;
$resourcegroup_name = &#039;resourcegroupname&#039;

$triggersADF = Get-AzDataFactoryV2Trigger -DataFactoryName $adf_name -ResourceGroupName $resourcegroup_name; 
$triggersADF | ForEach-Object { Start-AzDataFactoryV2Trigger -ResourceGroupName $resourcegroup_name -DataFactoryName $adf_name -Name $_.name -Force }
</pre></div>


<figure class="is-style-default wp-block-image size-large is-resized"><a href="https://marketplace.visualstudio.com/items?itemName=AzureOps.ssiscatalogerpro&amp;ssr=false#overview" target="_blank" rel="noopener"><img data-recalc-dims="1" loading="lazy" decoding="async" width="1200" height="148" data-attachment-id="4839" data-permalink="https://azureops.org/articles/azure-data-studio-for-sql-developers/scmw-horizontal-ad/" data-orig-file="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?fit=1326%2C163&amp;ssl=1" data-orig-size="1326,163" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="SCMW-horizontal-ad" data-image-description="" data-image-caption="" data-large-file="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?fit=1200%2C148&amp;ssl=1" src="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=1200%2C148&#038;ssl=1" alt="" class="wp-image-4839" style="object-fit:cover;width:811px;height:99px" srcset="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=1200%2C148&amp;ssl=1 1200w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=450%2C55&amp;ssl=1 450w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=600%2C74&amp;ssl=1 600w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=300%2C37&amp;ssl=1 300w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=768%2C94&amp;ssl=1 768w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?w=1326&amp;ssl=1 1326w" sizes="(max-width: 1200px) 100vw, 1200px" /></a></figure>



<h2 class="wp-block-heading">Manage ADF triggers in YAML based Azure DevOps pipeline</h2>



<p class="">Use the script below to enable and disable triggers in adf using a YAML-based]deployment pipeline in Azure DevOps.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: yaml; gutter: false; title: ; notranslate">
          deploy:  #Configure steps under deploy hook.
            steps:
              #task to disable triggers in Azure Data Factory.
              - task: AzurePowerShell@5     
                displayName: Stop Triggers
                inputs:
                  azureSubscription: &#039;subscriptionname&#039;
                  ScriptType: &#039;InlineScript&#039;
                  Inline: |
                    $triggersADF = Get-AzDataFactoryV2Trigger -DataFactoryName &quot;$(dataFactoryName)&quot; -ResourceGroupName &quot;$(resourceGroup)&quot;; 
                    $triggersADF | ForEach-Object { Stop-AzDataFactoryV2Trigger -ResourceGroupName &quot;$(resourceGroup)&quot; -DataFactoryName &quot;$(dataFactoryName)&quot; -Name $_.name -Force }
                  azurePowerShellVersion: &#039;LatestVersion&#039;             
             
              #task to enable triggers in Azure Data Factory.
              - task: AzurePowerShell@5    
                displayName: Start Triggers
                inputs:
                  azureSubscription: &#039;subscriptionname&#039;
                  ScriptType: &#039;InlineScript&#039;
                  Inline: |
                    $triggersADF = Get-AzDataFactoryV2Trigger -DataFactoryName &quot;$(dataFactoryName)&quot; -ResourceGroupName &quot;$(resourceGroup)&quot;;
                    $triggersADF | ForEach-Object { Start-AzDataFactoryV2Trigger -ResourceGroupName &quot;$(resourceGroup)&quot; -DataFactoryName &quot;$(dataFactoryName)&quot; -Name $_.name -Force }
                  azurePowerShellVersion: &#039;LatestVersion&#039;

</pre></div>


<p class="has-background" style="background-color:#bcefca"><strong>Pro tips:</strong><br>1. It is important to disable triggers before deploying data factory code using Azure DevOps pipelines. Refer to <a href="https://azureops.org/articles/automated-azure-data-factory-publish/" target="_blank" rel="noreferrer noopener">this</a> article if you want to automate Azure data factory deployments using the DevOps pipeline.</p>



<h2 class="wp-block-heading">See more</h2>



<iframe width="700" height="394" src="https://www.youtube.com/embed/t2h6xNVFQkc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="is-style-fill wp-block-button"><a class="wp-block-button__link has-white-color has-blush-light-purple-gradient-background has-text-color has-background has-link-color wp-element-button" href="https://azureops.org/product/ssis-catalog-migration-wizard-pro/" target="_blank" rel="noreferrer noopener">Download Now</a></div>
</div>
<p>The post <a href="https://azureops.org/articles/disable-and-enable-triggers-in-azure-data-factory/">Disable and Enable triggers in Azure Data Factory using PowerShell</a> appeared first on <a href="https://azureops.org">AzureOps</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">6310</post-id>	</item>
		<item>
		<title>Update Secret in Azure Key Vault using PowerShell</title>
		<link>https://azureops.org/articles/update-secret-in-azure-key-vault-using-powershell/</link>
		
		<dc:creator><![CDATA[Kunal Rathi]]></dc:creator>
		<pubDate>Wed, 26 Jul 2023 06:20:24 +0000</pubDate>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[Key Vault]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Azure key vault]]></category>
		<guid isPermaLink="false">https://azureops.org/?p=4667</guid>

					<description><![CDATA[<p>This article describes how to update secret in azure key vault using PowerShell using AAD and managed identity authentication.</p>
<p>The post <a href="https://azureops.org/articles/update-secret-in-azure-key-vault-using-powershell/">Update Secret in Azure Key Vault using PowerShell</a> appeared first on <a href="https://azureops.org">AzureOps</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class=""><a href="https://learn.microsoft.com/en-us/azure/key-vault/general/basic-concepts" target="_blank" rel="noreferrer noopener">Azure Key Vault</a> is a cloud service that helps store and securely access secrets. The secret could be anything we want to secure, like API keys, credentials, etc. It provides data encryption when moving from a key vault to a client application, making it more secure. It is possible to get and set key vault secrets programmatically. This article describes how to Update secret in Azure Key Vault using PowerShell.</p>



<p class="has-pale-cyan-blue-background-color has-background"><strong>Pre-requisites</strong>:<br>1. <a href="https://learn.microsoft.com/en-us/powershell/azure/new-azureps-module-az?view=azps-10.3.0" target="_blank" rel="noreferrer noopener">Azure Az PowerShell module</a> installed and you have the appropriate permissions to access and modify the Azure Key Vault. <br>2. Azure key vault with appropriate permissions.</p>



<h2 class="wp-block-heading"> Update key vault secrets using PowerShell</h2>



<p class="">Run below PowerShell command in any editor like PowerShell ISE.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: powershell; gutter: false; title: ; notranslate">
$azureTenantId = &quot;tenantid&quot;
$subscriptionId = &quot;subscriptionId&quot;
$keyVaultName = &quot;vaultname&quot;
&quot;&#039;Log in to Azure...&quot;
Connect-AzAccount -Tenant $azureTenantId  -Subscription $subscriptionId
Set-AzContext -TenantId $azureTenantId
$secretAccessKeyID = Set-AzKeyVaultSecret -VaultName $keyVaultName -Name &lt;key name&gt; -SecretValue &lt;secret value&gt; 
</pre></div>


<p class="">Here, </p>



<p class=""><code>Connect-AzAccount -Tenant $azureTenantId -Subscription $subscriptionId</code><br>This cmdlet connects to your Azure account using the specified Azure Tenant ID and Subscription ID. It initiates an authentication process to sign in to Azure.</p>



<p class=""><code>Set-AzContext -TenantId $azureTenantId</code><br>This cmdlet sets the context for the current session to the specified Azure Tenant ID. It ensures that it can perform subsequent operations in the context of the specified Azure tenant.</p>



<p class=""><code>$secretAccessKeyID = Set-AzKeyVaultSecret -VaultName $keyVaultName -Name &lt;key name&gt; -SecretValue &lt;secret value&gt;</code><br>This line updates a secret in the Azure Key Vault specified by <code>$keyVaultName</code>. It uses the <code>Set-AzKeyVaultSecret</code> cmdlet to perform this task. Replace <code>&lt;key name&gt;</code> with the name of the secret you want to update, and <code>&lt;secret value&gt;</code> with the new value for the secret.</p>



<h2 class="wp-block-heading"> Update secret in azure key vault using managed identity</h2>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: powershell; gutter: false; title: ; notranslate">
$azureTenantId =  &quot;tenantid&quot;
$keyVaultName = &quot;vaultname&quot;
&quot;&#039;Log in to Azure…&quot;
Connect-AzAccount -Identity
Set-AzContext -TenantId $azureTenantId
$secretAccessKeyID = Set-AzKeyVaultSecret -VaultName $keyVaultName -Name &lt;key name&gt; -SecretValue &lt;secret value&gt; 
</pre></div>


<figure class="is-style-default wp-block-image size-large is-resized"><a href="https://marketplace.visualstudio.com/items?itemName=AzureOps.ssiscatalogerpro&amp;ssr=false#overview" target="_blank" rel="noopener"><img data-recalc-dims="1" loading="lazy" decoding="async" width="1200" height="148" data-attachment-id="4839" data-permalink="https://azureops.org/articles/azure-data-studio-for-sql-developers/scmw-horizontal-ad/" data-orig-file="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?fit=1326%2C163&amp;ssl=1" data-orig-size="1326,163" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="SCMW-horizontal-ad" data-image-description="" data-image-caption="" data-large-file="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?fit=1200%2C148&amp;ssl=1" src="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=1200%2C148&#038;ssl=1" alt="" class="wp-image-4839" style="object-fit:cover;width:811px;height:99px" srcset="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=1200%2C148&amp;ssl=1 1200w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=450%2C55&amp;ssl=1 450w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=600%2C74&amp;ssl=1 600w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=300%2C37&amp;ssl=1 300w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=768%2C94&amp;ssl=1 768w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?w=1326&amp;ssl=1 1326w" sizes="(max-width: 1200px) 100vw, 1200px" /></a></figure>



<p class="">Here,</p>



<p class=""><code>Connect-AzAccount -Identity</code><br>To connect to Azure, this command uses the Managed Service Identity (MSI) of the current environment where the script is running. With MSI, you can access Azure resources without the need for explicit credentials in the code. However, it is important to note that this requires the environment to have a system-assigned or user-assigned managed identity with the necessary permissions to access the Azure Key Vault.</p>



<p class=""><code>Set-AzContext -TenantId $azureTenantId</code><br>This cmdlet sets the context for the current session to the specified Azure Tenant ID. It ensures that subsequent operations are performed in the context of the specified Azure tenant. The value for <code>$azureTenantId</code> was retrieved from the Azure Automation variable.</p>



<p class=""><code>$secretAccessKeyID = Set-AzKeyVaultSecret -VaultName $keyVaultName -Name &lt;key name&gt; -SecretValue &lt;secret value&gt;</code><br>This line updates a secret in the Azure Key Vault specified by <code>$keyVaultName</code>. It uses the <code>Set-AzKeyVaultSecret</code> cmdlet to perform this task. Replace <code>&lt;key name&gt;</code> with the name of the secret you want to update, and <code>&lt;secret value&gt;</code> with the new value for the secret.</p>



<p class="has-background" style="background-color:#bcefca"><strong>Pro tips:</strong><br>1. Be cautious while updating secrets; they are sensitive information and should be handled securely.<br>2. While we can only change secret attributes such as expiration date, activation date. However, we can add a new version of the existing secret<br>3. Follow <a href="https://azureops.org/articles/key-vault-secrets-in-azure-data-factory/" target="_blank" rel="noreferrer noopener">this</a> article if you want to learn how to access key vault secrets in Azure Data Factory.</p>



<h2 class="wp-block-heading">See more</h2>



<iframe width="700" height="394" src="https://www.youtube.com/embed/t2h6xNVFQkc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="is-style-fill wp-block-button"><a class="wp-block-button__link has-white-color has-blush-light-purple-gradient-background has-text-color has-background has-link-color wp-element-button" href="https://azureops.org/product/ssis-catalog-migration-wizard-pro/" target="_blank" rel="noreferrer noopener">Download Now</a></div>
</div>



<p class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p>The post <a href="https://azureops.org/articles/update-secret-in-azure-key-vault-using-powershell/">Update Secret in Azure Key Vault using PowerShell</a> appeared first on <a href="https://azureops.org">AzureOps</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4667</post-id>	</item>
		<item>
		<title>Export Measures From Power BI Desktop</title>
		<link>https://azureops.org/articles/export-measures-from-power-bi/</link>
		
		<dc:creator><![CDATA[Kunal Rathi]]></dc:creator>
		<pubDate>Sun, 26 Feb 2023 18:19:37 +0000</pubDate>
				<category><![CDATA[Power BI]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[DAX]]></category>
		<category><![CDATA[Export Power BI measures]]></category>
		<category><![CDATA[Power BI measures]]></category>
		<guid isPermaLink="false">https://azureops.org/?p=4952</guid>

					<description><![CDATA[<p>This article describes how to export measures from Power BI Desktop using the Power BI template.</p>
<p>The post <a href="https://azureops.org/articles/export-measures-from-power-bi/">Export Measures From Power BI Desktop</a> appeared first on <a href="https://azureops.org">AzureOps</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="">Power BI is a widely used reporting tool in the market today. A Power BI  Desktop file contains all DAX measures and calculated columns to build the visualizations using the data model. With growing calculated measures and columns, sometimes, we might need to export them into a file or repository for documentation purpose. This article describes how to export measures from Power BI Desktop using the Power BI template.</p>



<h2 class="wp-block-heading">What is a Power BI template file? </h2>



<p class="">The PBIT file keeps your report structure and contains&nbsp;‘DataModelSchema File’ instead of ‘‘DataModel file. This means it doesn&#8217;t include any data from your source systems, and the size of this file is very small. However, it has Report&nbsp;pages, visuals, &nbsp;data model definitions, and query definitions. Read more about it <a href="https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-templates" target="_blank" rel="noreferrer noopener">here</a>.</p>



<h2 class="wp-block-heading">Steps to export measures from Power BI file.</h2>



<h3 class="wp-block-heading">1. Save the Power BI file as Power BI template (.pbit)</h3>



<p class="">1. Open the Power BI (.pbix) file in PowerBI Desktop.</p>



<p class="">2. Click on the File menu item and click Save. Click &#8216;Browse this device&#8217;  button at the bottom left side. </p>



<p class="">3. Select the Template (.pbit) file type and give a name to the Power BI template file as shown in the below image.</p>



<figure class="wp-block-image size-full"><img data-recalc-dims="1" loading="lazy" decoding="async" width="1200" height="345" data-attachment-id="5118" data-permalink="https://azureops.org/articles/export-measures-from-power-bi/export-power-bi-measurs-from-pbix-file/" data-orig-file="https://i0.wp.com/azureops.org/wp-content/uploads/2023/02/Export-Power-BI-measurs-from-pbix-file.gif?fit=1200%2C345&amp;ssl=1" data-orig-size="1200,345" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Export-Power-BI-measurs-from-pbix-file" data-image-description="" data-image-caption="" data-large-file="https://i0.wp.com/azureops.org/wp-content/uploads/2023/02/Export-Power-BI-measurs-from-pbix-file.gif?fit=1200%2C345&amp;ssl=1" src="https://i0.wp.com/azureops.org/wp-content/uploads/2023/02/Export-Power-BI-measurs-from-pbix-file.gif?resize=1200%2C345&#038;ssl=1" alt="Export Measures From Power BI Desktop - Save as Power BI file to Power BI template (pbit)" class="wp-image-5118" srcset="https://i0.wp.com/azureops.org/wp-content/uploads/2023/02/Export-Power-BI-measurs-from-pbix-file.gif?w=1200&amp;ssl=1 1200w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/02/Export-Power-BI-measurs-from-pbix-file.gif?resize=450%2C129&amp;ssl=1 450w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/02/Export-Power-BI-measurs-from-pbix-file.gif?resize=600%2C173&amp;ssl=1 600w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/02/Export-Power-BI-measurs-from-pbix-file.gif?resize=300%2C86&amp;ssl=1 300w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/02/Export-Power-BI-measurs-from-pbix-file.gif?resize=768%2C221&amp;ssl=1 768w" sizes="(max-width: 1200px) 100vw, 1200px" /></figure>



<h3 class="wp-block-heading">2. Run below PowerShell script.</h3>



<p class="">Copy the below PowerShell script in PowerShell ISE and provide the path to the folder containing the Power BI template file (.pbit) exported in step 1 to variable <code>$pbitFolderPath</code>. Also, give the name of the template file to the <code>$pbiFileName</code> variable.</p>



<figure class="is-style-default wp-block-image size-large is-resized"><a href="https://marketplace.visualstudio.com/items?itemName=AzureOps.ssiscatalogerpro&amp;ssr=false#overview" target="_blank" rel="noopener"><img data-recalc-dims="1" loading="lazy" decoding="async" width="1200" height="148" data-attachment-id="4839" data-permalink="https://azureops.org/articles/azure-data-studio-for-sql-developers/scmw-horizontal-ad/" data-orig-file="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?fit=1326%2C163&amp;ssl=1" data-orig-size="1326,163" data-comments-opened="0" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="SCMW-horizontal-ad" data-image-description="" data-image-caption="" data-large-file="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?fit=1200%2C148&amp;ssl=1" src="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=1200%2C148&#038;ssl=1" alt="" class="wp-image-4839" style="object-fit:cover;width:811px;height:99px" srcset="https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=1200%2C148&amp;ssl=1 1200w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=450%2C55&amp;ssl=1 450w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=600%2C74&amp;ssl=1 600w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=300%2C37&amp;ssl=1 300w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?resize=768%2C94&amp;ssl=1 768w, https://i0.wp.com/azureops.org/wp-content/uploads/2023/01/SCMW-horizontal-ad.png?w=1326&amp;ssl=1 1326w" sizes="(max-width: 1200px) 100vw, 1200px" /></a></figure>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: powershell; gutter: false; highlight: [4,5]; title: ; notranslate">
#Path containing pbit file
#Parameters
################################################################
$pbitFolderPath = &quot;D:\PowerBI files\&quot;
$pbiFileName = &quot;Sample PBI&quot;
################################################################
$pbitFileName = $pbiFileName  + &quot;.pbit&quot;
$pbitFilePath = $pbitFolderPath + $pbiFileName  + &quot;.pbit&quot;
$zipFileName =  $pbiFileName + &quot;.zip&quot;;
$exportMeasuresFilePath = $pbitFolderPath +$pbiFileName + &#039; Calculations.csv&#039;
$zipFileFullPath = $pbitFolderPath + $zipFileName

#Rename pbit file to zip file.
Rename-Item -Path $pbitFilePath -NewName  $zipFileName

#Temp. export file path
$exportPath = $pbitFolderPath + &quot;export\&quot;

#Unzip zip file
Expand-Archive -Path $zipFileFullPath -DestinationPath $exportPath

#DataModelSchema file full path
$dataModelSchemaFullPath =  $exportPath + &quot;DataModelSchema&quot;
$strFileName = &quot;DataModelSchema.json&quot;

#Rename DataModelSchema file to DataModelSchema.json
Rename-Item -Path $dataModelSchemaFullPath -NewName  $strFileName 

#Get the JSON from DataModelSchema.json
$dataModelSchemaJsonFullPath = $exportPath + $strFileName

$jsonStr = Get-Content $dataModelSchemaJsonFullPath -Encoding unicode | Out-String

#Convert the Json to a dynamic object
$outJson = ConvertFrom-Json $jsonStr 

#Extract the tables to a list
$outTables = $outJson.Model.tables

&quot;Table Name, Calculation Type, Calculation Name, Value&quot; | Out-File $exportMeasuresFilePath  

#Remove hidden system generated date tables.
$outTables = $outTables | Where-Object {$_.isHidden -ne $true}

foreach ($outTable in $outTables) 
# Foreach Table in Power BI desktop
{
if ($outTable.measures -ne $null) 
{
$outMeasures = $outTable.measures
foreach ($outMeasure in $outMeasures) 
{
 $(&quot;{0} , {1} , {2}, {3}&quot; -f $outTable.name, &quot;Measure&quot;, $outMeasure.name, $outMeasure.expression -join &quot; &quot; | Out-String)  | Out-File $exportMeasuresFilePath  -Append
# Write the measure and expression 
}
 }
  if ($outTable.columns -ne $null) 
  { 
  $outColumns = $outTable.columns
  $outColumns = $outColumns | Where-Object {$_.type -eq &quot;calculated&quot;} 
  # Filter on calculated columns only, but this could be removed for all 
  foreach ($outColumn in $outColumns) 
  { 
   $(&quot;{0} , {1} , {2}, {3}&quot; -f $outTable.name, &quot;Calculated column&quot; , $outColumn.name, $outColumn.expression -join &quot; &quot;) | Out-File $exportMeasuresFilePath  -Append
  }
}
}
write-host &quot;Calculations written to &quot;$exportMeasuresFilePath 

Rename-Item -Path  $zipFileFullPath -NewName  $pbitFileName

#Clenaup temp files
Remove-Item $exportPath -Recurse
</pre></div>


<p class="">The output of the above script execution will be stored in &#8216;&lt;PowerBI filename&gt; calculation.csv&#8217; file in the same folder containing the Power BI template file. The result might not be well-formatted csv as the exported calculations can have &#8216;,&#8217; in its definitions.</p>



<p class="has-background" style="background-color:#bcefca"><strong>Pro tips:</strong><br>1.  Output of the above PowerShell script also includes calculated column expressions. <br>2. If you are using <a href="https://www.sqlbi.com/tools/dax-studio/" target="_blank" rel="noreferrer noopener">DAX Studio</a>, you can also export measures from Power BI using Dax Studio <br>3. To test row-level security, you can read <a href="https://azureops.org/articles/run-power-bi-report-as-different-user/" target="_blank" rel="noreferrer noopener">this</a> post if you want to run the Power BI report as a different user.</p>



<h2 class="wp-block-heading">See more</h2>



<iframe width="700" height="394" src="https://www.youtube.com/embed/t2h6xNVFQkc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>



<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="is-style-fill wp-block-button"><a class="wp-block-button__link has-white-color has-blush-light-purple-gradient-background has-text-color has-background has-link-color wp-element-button" href="https://azureops.org/product/ssis-catalog-migration-wizard-pro/" target="_blank" rel="noreferrer noopener">Download Now</a></div>
</div>
<p>The post <a href="https://azureops.org/articles/export-measures-from-power-bi/">Export Measures From Power BI Desktop</a> appeared first on <a href="https://azureops.org">AzureOps</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4952</post-id>	</item>
	</channel>
</rss>
