Azure If Logic in Data Factory Pipelines is a powerful tool that allows you to conditionally execute activities based on specific conditions.
You can use the "If" activity to check if a file exists, or if a value meets a certain criteria, and then execute a different activity accordingly.
The "If" activity in Data Factory Pipelines is similar to the "If" statement in programming languages, allowing you to write conditional logic to control the flow of your pipeline.
For example, you can use the "If" activity to check if a file is present in a folder, and if it is, then copy it to a different location.
In Azure Data Factory, the "If" activity is used to implement conditional logic in your pipelines, allowing you to make decisions based on specific conditions.
Azure Data Factory Pipeline
Creating an Azure Data Factory pipeline is a powerful way to automate data transfer tasks. You can customize your pipeline to make it more intelligent by adding conditions to check the input file's name.
To prepare the destination for the second activity, you'll need to create a table inside your database. For example, the script to create the DimCurrency table inside DstDb is a simple SQL query.
The If Condition activity is a crucial part of an intelligent pipeline. It allows you to evaluate a condition and execute different activities based on the result. In the example, the If Condition activity is used to check if the input file's name starts with 'FactIntSales'.
You can use the bool function to evaluate a condition in the If Condition activity. The expression @bool(startswith(pipeline().parameters.SourceFile,'FactIntSales')) checks if the input file's name starts with 'FactIntSales'. This is a common use case for the If Condition activity.
To add activities to the True and False evaluation groups, you'll need to click the Add If True Activity button. You can then paste the activity you copied earlier into the buffer and assign a name to it. In the example, the activity FactInternetSales_AC is pasted into the buffer and assigned a name.
Explicit field mapping is not necessary when transferring files with different structures. You can switch to the Mapping tab and click the Clear button to remove mapping. This is done in the FactInternetSales_AC activity, which originally had explicit field mapping.
Deployment and Error Handling
When you're working with Azure If, you'll want to consider how to handle deployments and errors. You can customize the What-If operation settings to suit your needs.
The resultFormat setting determines the format of the What-If results. This is a crucial setting to get right, as it will affect how you interpret the results.
You can choose from a variety of deployment options for when errors occur. The deploymentName setting specifies the deployment to be used in the event of an error.
The type setting determines the deployment on error behavior type. You have two options: LastSuccessful or SpecificDeployment.
Here are the possible values for the type setting:
Data Factory Condition Activity
You can create a Data Factory Condition Activity to make your pipeline more intelligent by checking the input file's name and transferring files into different tables accordingly.
To prepare the destination for the second activity, you need to create a table inside DstDb using a script.
The If Condition activity is used to evaluate a condition based on the input file's name. The condition is created using the bool function and the startswith function.
You can add activities to the True and False evaluation groups by selecting the If Condition activity and clicking the Add If True Activity button.
The activity FactInternetSales_AC originally has explicit field mapping, but you can switch to the Mapping tab and click the Clear button to remove mapping.
You can validate the Azure Data Factory pipeline execution by initiating it and examining the execution results in the Monitor screen.
Conditional validation is used to run different activities based on the condition. For example, the DimCurrency_AC activity ran after conditional validation.
The Activity Runs screen confirms that the conditional activity worked as expected, and the pipeline executed accordingly.
Operation and Change
The What-If operation in Azure can predict changes to your resources, but did you know it also provides information about a single resource change? This is where the WhatIfChange object comes in.
The WhatIfChange object contains several properties, including the predicted snapshot of the resource after the deployment is executed, which is referred to as the after object. This is a snapshot of the resource after the deployment is executed.
The before object, on the other hand, is the snapshot of the resource before the deployment is executed. This is a crucial piece of information, as it allows you to see the changes that will be made to the resource.
The changeType property indicates the type of change that will be made to the resource when the deployment is executed. This can be a valuable insight into what to expect from the deployment.
The delta property, which is an array of WhatIfPropertyChange objects, contains the predicted changes to resource properties. This can help you understand the specifics of the changes that will be made to the resource.
The resourceId property is simply the ID of the resource, which can be useful for referencing the resource in question. The unsupportedReason property, however, is a bit more interesting. It provides an explanation about why the resource is unsupported by What-If, which can be helpful in troubleshooting issues.
Here's a summary of the WhatIfChange object properties:
The What-If operation result, on the other hand, contains a list of predicted changes and a URL link to get to the next set of results. This is contained within the WhatIfOperationResult object, which is an array of WhatIfChange objects.
Sources
- https://www.mssqltips.com/sqlservertip/6138/azure-data-factory-if-condition-activity/
- https://learn.microsoft.com/en-us/answers/questions/205846/azure-data-factory-pipeline-if-condition
- https://learn.microsoft.com/en-us/rest/api/resources/deployments/what-if
- https://learn.microsoft.com/en-us/entra/identity/conditional-access/concept-conditional-access-cloud-apps
- https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-portal
Featured Images: pexels.com