Search code examples
azurepowershellazure-data-factoryazure-powershell

Can't use Az.Datafactory in Powershell because my factory is the wrong resource type


I'm trying to use Az.Datafactory module in Powershell to interact with my data factory. I've created this factory in the Azure portal. But the module can't seem to find the factory, because it's resource type is Microsoft.DataFactory/factories, but Az.Datafactory looks in Microsoft.DataFactory/dataFactories.

Name                                 ResourceType                                       Location      
----                                 ------------                                       --------
sqlCdc1                              Microsoft.DataFactory/factories                    eastus
testFactoryBD                        Microsoft.DataFactory/factories                    canadaeast

Here is the error message:

Get-AzDataFactory : HTTP Status Code: NotFound
Error Code: ResourceNotFound
Error Message: The Resource 'Microsoft.DataFactory/dataFactories/sqlCdc1' under resource group 'BD_prelimTests' was not found. For more details please go to
https://aka.ms/ARMResourceNotFoundFix
Request Id: f5407d39-57e1-4d10-a706-e55522467a99
Timestamp (Utc):03/21/2023 14:46:22
Au caractère Ligne:1 : 1
+ Get-AzDataFactory -ResourceGroupName BD_prelimTests -Name sqlCdc1

My Azure portal puts data factories by default in /factories. When I try to create a factory with Az.Datafactory in Powershell to see if the factory will be created in /dataFactories, it says it cannot create a factory in my region (canadaeast). When I try with a different region (eastus), it says my tenant doesn't allow data factory creation in that region, even though I can do it in the Azure portal as you can see above.


Solution

  • The Module which you are using is tied to Data Factory V1 and not V2 version. Please leverage : Get-AzDataFactoryV2 https://learn.microsoft.com/en-us/powershell/module/az.datafactory/get-azdatafactoryv2?view=azps-9.5.0