Tuesday, 21 February 2023

Bug In Azure API creating Data Factory Default AutoResolveIntegrationRuntime on Managed Virtual Network

Recently our terraform Infrastructure as code effort to create a datafactory resource with default AutoResolveIntegrationRuntime in Managed Virtual Network failed to create one.

We had managed_virtual_network_enabled flag on terraform and tried to use native azure cli too as a backup but both failed to create the default integration runtime on Managed Virtual Network and created a default public integration runtime. Only work around it was to create a Data Factory using ARM Template. I exported the ARM template and created the below Powershell to create the Data factory. I stored the Template and parameter file on a Fileshare and used it in the powershell to reuse and create a parameter file each time for different DF creation.
connect-AzAccount
$client = "<client>"
$environment = "<environment>"
$tenantid = '<tenant-id>'
$subscriptionid = <subscription-id>
Select-AzSubscription $subscriptionid
$ssisdfrg = 'sqltechnet'-df-rg'
$ssisdf = 'sqltechnet'-mvnet-df'
$ssisstgacctname = 'ssisstgacct'
$dfobj = @()
$dfobj = Get-AzDataFactoryV2 -ResourceGroupName $ssisdfrg |Where{$_.DataFactoryName -eq $ssisdf}|SELECT *
if(!$dfobj)
{
$corergobj = Get-AzResourceGroup -Name $ssisdfrg
$dfarmparameter = Get-Content -Path \\sqltechnet.file.core.windows.net\CloudAutomation\parameters.json
$dfarmparameter = $dfarmparameter.Replace('<insert-subscription-id>',$subscriptionid)
$dfarmparameter = $dfarmparameter.Replace('<insert-rg-id>',$ssisdfrg)
$dfarmparameter = $dfarmparameter.Replace('<insert-df-id>',$ssisdf)
$dfarmparameter = $dfarmparameter.Replace('<insert-location-id>',$corergobj.Location)
$envparameterfile = '\\sqltechnet.file.core.windows.net\CloudAutomation\sqltechnet'+'_'+'DF_parameters.json'
$envtemplatefilefile = '\\sqltechnet.file.core.windows.net\CloudAutomation\template.json'
Set-Content -Path $envparameterfile -Value $dfarmparameter -Force
New-AzResourceGroupDeployment -ResourceGroupName $ssisdfrg -TemplateParameterFile $envparameterfile -TemplateFile $envtemplatefilefile
}
else
{Write-Host "DataFactory " $ssisdf "on Resourcegroup "$ssisdfrg "Already exists" }
Remove-Variable * -ErrorAction SilentlyContinue;
Copyright © 2023 Vinoth N Manoharan.The information provided in this post is provided "as is" with no implied warranties or guarantees.

No comments:

Post a Comment