Search code examples
powershellazure-pipelines-release-pipelinerelease-managementazure-data-factory

Automate Azure Data Factory triggers using release pipeline by using powershell task


I am new on DevOps, i am trying to change Azure Data Factory triggers starttime and endtime properties in azure data factory at deployment time using powershell.

I found this link and tried to follow in PowerShell. I am getting following error when i am running below command.

PS C:\> Set-AzDataFactoryV2Trigger -ResourceGroupName "ADF" -DataFactoryName "WikiADF" -Name "ScheduledTrigger" -DefinitionFile ".\scheduledTrigger.json"

Set-AzureRmDataFactoryV2 : The term 'Set-AzureRmDataFactoryV2' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

At line:1 char:16
+ $DataFactory = Set-AzureRmDataFactoryV2 -ResourceGroupName $ResGrp.Re ...
+                ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Set-AzureRmDataFactoryV2:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

I searched about this issue and found this issue as a bug in Microsoft official github account

If anyone able to resolved this issue or have already resolved, please help me.

Note: Azure DataFactory Triggers tag is not available in StackOverflow, so i am not able to add it.


Solution

  • Very agreed with Nick's opinion:

    Any time youe see The term 'xyz' is not recognized as the name of a cmdlet in powershell, it means you haven't installed the module.

    Actually, in your issue, the error also caused by this reason. I think you should haven't installed the Az module for your Powershell.

    The Az module is a rollup module for the Azure PowerShell cmdlets. Installing it can download all of the available Azure Resource Manager modules, include the Set-AzDataFactoryV2Trigger you are using, and makes their cmdlets available for use.

    Try this command to install the Az module for your Powershell:

    Install-Module -Name Az -AllowClobber -Scope CurrentUser
    

    enter image description here

    Since as default, the PowerShell gallery isn't configured as a trusted repository for PowerShellGet, the first time you use the PSGallery you would see the prompt which need you ensure if you want to get the Az module from PSGallery. Just answer Yes or Yes to All is ok.

    Then, you can execute the following command to check the Az module:

     Get-InstalledModule -Name Az
    

    When you see the following message, it means the Az module has exists in the Powershell:

    enter image description here

    Now, try this link again, it would be succeed.