Azure Data Factory - How to remove data sets in bulk? - azure

How to remove data sets in bulk? I have many data sets but could not find an option on the UI how to delete them all, neither I could find a powershell command.

While there is no such option to delete all datasets in the portal, you can do so with a PowerShell snippet:
Get-AzureRmDataFactory -ResourceGroupName <rgname> -Name <factory name> | Get-AzureRmDataFactoryDataset | Remove-AzureRmDataFactoryDataset
You may wish to append -Force to Remove-AzureRmDataFactoryDataset, which will stop the cmdlet from prompting you before deleting each dataset. Keep in mind that datasets cannot be deleted if they are being referenced by some existing pipeline.

I have not found this option but I created a ps1 script file with Remove-AzureRMDataFactoryDataset statement for each dataset and with -force parameter and then ran it via powershell. It did the job.

Microsoft has updated the version of powershell command for azure data factory. If you want to run above query successfully, now you need to use the V2 version which shows below
Get-AzureRmDataFactoryV2 -ResourceGroupName <rgname> -Name <factory name> | Get-AzureRmDataFactoryV2Dataset |Remove-AzureRmDataFactoryV2Dataset -Force

Related

How to get the details of the all Azure VM's with respective all Tag associated with it in excel sheet with the help of powershell?

How can I write a PowerShell script to get the report of all azure VMs in an excel spreadsheet, which includes the All tags associated with that, RG, and subscription?
You can implement the Powershell Script by following steps:
Install az modules in your local machine (Install-Module -Name 'Az' -allowclobber -scope currentuser)
Connect to your Azure subscription using this cmd (connect-Azaccount).
Use Get-AzVm Get-AzVM (Az.Compute) | Microsoft Docs to get the list of VM under the subscription and assign the output to a variable and by using the for each loop about Foreach - PowerShell | Microsoft Docs iterate the list in the variable and project the output to csv file using the export-csv.

Remove trigger reference from pipeline in azure data factory using powershell

I have a pipeline which has trigger associated in azure data factory. I am trying to automate some of operations in azure data factory using powershell commands. In one use case , I am blocked.
Use Case: User changed pipeline name which has trigger associated. (This is sample only, in reality many pipelines/triggers may be there in data factory, user may change single or many pipelines)
Trigger Name: TRG_Test1
Pipeline Name: PL_Test1
So TRG_Test1 trigger is attached to pipeline PL_Test1.
Requirement: user changed name from PL_Test1 to PL_Test1_Updated , the associated trigger should be detach(remove) from pipeline and then remove pipeline and create new pipeline with new name and attach(associate) same trigger.
Note: There are no changes in trigger details, only pipelines details changed.
By workaround using powershell, I am able to identify for which pipeline has which trigger associated using powershell script. But I am unable to detach pipeline before removing pipeline.
Error:
The document cannot be deleted since it is referenced by
Set-AzDataFactoryV2Trigger : I am using this powershell command when trigger is detached from pipeline and changes to affect in pipeline.
Is there any powershell command to remove only pipeline references?
Any alternative /Work around process to remove references of pipelines?
## Detach/Update the trigger
Set-AzDataFactoryV2Trigger -ResourceGroupName $ADFDeployResourceGroupName -Name $triggerName -DataFactoryName $DataFactoryName -File /$triggerName.json" -Force
##Remove Pipeline
#Remove-AzDataFactoryV2Pipeline -ResourceGroupName $ADFDeployResourceGroupName -Name $PipelineFileName -DataFactoryName $DataFactoryName -Force
If you want to remove the pipeline references in the trigger, please refer to the following code
Connect-AzAccount
$sub=""
$groupName=""
$factoryName=""
$triggerName=""
Select-AzSubscription -Subscription $sub
$sw=Get-AzResource -ResourceId "/subscriptions/$sub/resourceGroups/$groupName/providers/Microsoft.DataFactory/factories/$factoryName/triggers/$triggerName“ -ExpandProperties
#remove the piplines reference
$pipName="Test" // the pipeline you want to remove
$sw.Properties.pipelines =($sw.Properties.pipelines -ne ($sw.Properties.pipelines|Where-Object{$_.pipelineReference.referenceName -eq $pipName}))
$s=Set-AzResource -ResourceId "/subscriptions/$sub/resourceGroups/$groupName/providers/Microsoft.DataFactory/factories/$factoryName/triggers/$triggerName“ -Properties $sw.Properties -Force

Update Azure Data Factory Properties for Datasets/Pipelines/Linked Services/Triggers using PowerShell

What is Power shell command for Updating Properties of either (datasets/Pipelines/Triggers) in Azure Data factory?
Ex: Set-AzDataFactoryV2Pipeline - create/update a pipeline in Azure Data factory.
Incase Set-AzDataFactoryV2Pipeline command can useful for updating pipeline, How can I set new name properties ?which parameter in this command suitable for renaming pipeline?
But I want to know command which can update properties such as Pipeline Name/ Trigger Name /Dataset Name.
According to the official document, there is no update command about Pipeline Name/ Trigger Name /Dataset Name.
I think we have two ways to rename them.
Using powershell, we need to remove the resources first and then create it again.
Here I take the pipeline as an example:
Remove-AzDataFactoryV2Pipeline -ResourceGroupName "<ResourceGroupName>" -Name "<PipelineName>" -DataFactoryName "<DataFactoryName>"
Set-AzDataFactoryV2Pipeline -ResourceGroupName "<ResourceGroupName>" -Name "<PipelineName>" -DataFactoryName "<DataFactoryName>" -File ".\***.json"
Using Azure Data Factory UI, we can rename them in place easily.
Here I take the pipeline as an example:

Azure ARM: Remove-AzureRmKeyVault -Force not working

In Azure RM Powershell the statement
Remove-AzureRmKeyVault -InputObject $sdvobjKeyVault -Force
always pops up with the prompt whether I really want to execute that action - '-Force' seems to get ignored! Now then, how to have a KV deleted from a RG without user interaction via Azure Powershell?
I'm not seeing the same behavior here. Adding -Force suppresses the confirmation as expected.
Any reason you are using the old AzureRm commands? You should start making the move to the Az commands. Here is a good reference for KeyVaults including the ability to manage the Soft Delete for vaults.
MS Docs Reference: https://learn.microsoft.com/en-us/azure/key-vault/key-vault-soft-delete-powershell

Get-azureRmDisk does not show property DiskState

I need to get property like "DiskState", I am using cmd-let Get-AzureRMdisk, and what I got:
1) from my laptop, using connect-azurermaccount then get-azurermdisk, doesnt give expected property 2) I tried from Automatio account, created a runbook and then paste my code there, the same, I got more values but didn't get "diskstate" value 3) I see that I can get it from Azure Cloud Shell console. I would like to get this value from a script running as a runbook. Moreover I tried to use command like --> Get-AzureRmDisk | Where-Object ManagedBy -ne $null, but didnt get any interesting results. Is there any matheto do get this mentioned property "diskstate" using powershell runbook from Automation account?
Why not, the PowerShell command Get-AzureRMDisk show you the DiskState as you want:
Additional, I recommend you use the Az module of the PowerShell while the AzureRM module is Migrated to it. See Migrate Azure PowerShell from AzureRM to Az.
Update:
But in the Runbook Get-AzureRMDisk does not show the property, you need to use the Get-AzDisk to achieve the purpose after you import the Az module and it shows like this:

Resources