Unable to export 'Microsoft.DataFactory/factories' schema using powershell - powershell

Am trying to export ARM template for a resourcegroup where in i have Azure data factory, but when using "Export-AzureRmResourceGroup" it throws a warning as below and none of ADF schema is downloaded in that template. is there a way to download ADF template using powershell??
Export-AzureRmResourceGroup -ResourceGroupName ****************
WARNING: ExportTemplateCompletedWithErrors : Export template operation completed with errors. Some resources were not exported. Please see details for more information.
WARNING: ResourceTypeSchemaNotFound : The schema of resource type 'Microsoft.Databricks/workspaces' is not available. Resources of this type will not be exported to the template.
WARNING: ResourceTypeSchemaNotFound : The schema of resource type '**Microsoft.DataFactory/factories**' is not available. Resources of this type will not be exported to the template.
WARNING: ResourceTypeSchemaNotFound : The schema of resource type 'Microsoft.Portal/dashboards' is not available. Resources of this type will not be exported to the template.

As mentioned there, DataFactory template export is not supported yet.
BUT, there is a solution which we've used in our CI/CD.
First, we've created a dummy generic template for the datafactory (see the steps below), and then used either ARM template exported from the datafactory template or adf_publish (see the notes below) branch to update and finalize the datafactory.
To create a dummy datafactory template:
On the portal try to create a dummy datafactory, and click on "Automation options" (instead of "Create")
This will create an empty datafactory ARM template, which then you can use for your pipelines. Now just click on the "Download" button and store the dummy template somewhere.
Afterwards you can use that template to create a new dummy datafactory if it doesn't exist, and then update it with the real ARM templates provided by either the "Export ARM Template" button inside the datafactory, or the adf_publ
Notes:
1. We came to this solution as the ARM templates which were provided* by the azure portal, were not including the Datafactory resource itself, because of which deployment to a new Resource Group was FAILING.
So, we had to create a dummy DataFactory first, and then update it with actual DataFactory template.
2. By saying "provided* by the azure portal" we mean the ARM templates which are provided when you open the DF and click on "ARM Template" > "Export ARM template", or the one published in adf_publish branch
3. For creating CI/CD we used the other steps mentioned there

This is because those "ResourceTypeSchemas" are not available to use in ARM templates. It doesn't matter if you go into the portal and try to get the resource template. It will show the same error there as well.

You get exactly the same thing when you are trying to do via Azure directly:
However there's a template defined by Microsoft for almost any object, which you can access in here, so if you're starting from scratch, this can be a good starting point to create your template.
If you already have something defined in your existing data factory, then you just need to export ARM template directly from your data factory and merge extracted template with the one from Microsoft documentation.
For this to work you need to include two nodes, because the yare not currently included in this export functionality: for generating the data factory itself
{
"type": "Microsoft.DataFactory/factories",
"apiVersion": "2018-06-01",
"name": "[parameters('dataFactoryName')]",
"location": "[parameters('location')]",
"identity": {
"type": "SystemAssigned"
}
}
and you will also probably need a template for storage account
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-08-01",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2"
}

If all you need is the template, and if you are trying to download via PowerShell, then I assume you have access to that RG.So navigate to Azure Portal->Resource Group ( that has the ADF or any resource that you need. From the left nav bar , you'll find this Automation Script .
Click on it and the template will appear. From here, you can download the template directly

Related

Azure Data Factory - Azure DevOps - The assigned "user assigned managed identity" for target ADF gets removed when deploying to it, failing deployment

I have two environments for the ADF, the "Dev" and "UAT".
I have assigned both of the environments to the same "User Assigned Managed Identity" that I use in my credential to authenticate target sources.
Dev Assigned Managed Identity
UAT Assigned Managed Identity before the deployment
It works as expected in the "Dev" environment, and the question is not about how to use managed identity. The problem is when I try to deploy the ARM template to "UAT" through the Azure DevOps release pipeline and the deployment fails.
I have identified exactly why that is happening but can't figure out how to overcome the problem.
Essentially the deployment step drops the assigned "User Assigned Managed Identity" from the "UAT" Data Factory settings.
UAT Managed Identities after deployment
As a result, because the UAT ADF environment does not have it, the deployment fails with the following error.
Error
Essentially saying, in the UAT Environment, there is no "User Assigned Managed Identity" associated with the factory and the credential is unable to find it and use it.
I use ARM Template Deployment V 3.*
ARM Template Deployment
The deployment mode used is "Incremental"
Forgot to mention, the CI/CD ADF Pipeline has been set up and I have been using it for a while, the issue with deployment started only when I tried to utilise managed identities instead of keys.
Any pointers would be greatly appreciated.
I have found the origin of the problem as well as the solution.
Even though I have assigned both "System Assigned Managed Entity" and "User Assigned Managed Identity" against the "Dev" environment, the "Dev" ARM template still defaulted its parameter value at only "System Assigned Managed Entity"
System Assigned Managed Entity Parameter Inside the ARM Template
Hence, when publishing, the said parameter would get picked up and remove the UAMI I have set up previously.
There are a few ways to approach it but the one I used was to change the contents of the ARMTemplateForFactory.json.
Step 1. Add an extra parameter in the "Parameters": {}
"uamiName": {
"type": "string",
"defaultValue": "YourUamiHere"
}
Step 2. Change "identity" from
"identity": {
"type": "[parameters('dataFactory_identity_type')]"
}
To
"identity": {
"type": "SystemAssigned,UserAssigned",
"userAssignedIdentities": {
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('uamiName'))]": {}
}
}
You can also then override template parameters in the ARM Template Deployment to use different UAMI in other environments.

Adding custom parameter to ADF ARM template

I have an ADF pipeline. The task is to productionize the pipeline. I am using azure devops CI/CD (classic). I am following this documentation
https://learn.microsoft.com/en-us/azure/data-factory/continuous-integration-delivery-resource-manager-custom-parameters
I have to move the pipeline to test and prod. Thereforem, there are many parameters that are parametrized but few parameters like sql user_name, secret_name are not parametrized.
I want to edit the ARM template and add custom parameter so that I do not have to edit the template.json and paramete-template.json and push them again to repo. The edit option in adf allows to create custom params and therefore generate these in ARM templates when exported.
I have the parameter in the template.
The parameter secretName doesnt appear in ARM template in CD flow
Which mode you are using to configure the parameters?
ARM parameter configuration is only enabled in "GIT mode". Currently it is disabled in "live mode" or "Data Factory" mode.
So, as per above official statement from Microsoft, you should be using Git repository.
Also, take note - Creating a custom Resource Manager parameter configuration creates a file named arm-template-parameters-definition.json in the root folder of your git branch. You must use that exact file name.
There are other multiple ways which you can try to pass secrets in ARM template. Refer this article from devkimchi.com.
After lot of tries and understanding the credential structure the ADF follows for different LinkedServices, we have found that to parametrize a custom nested argument, we have to specify the argument in a nested form. The parameter configuration needs to be edited like this:
For example, the secret name for SQL linked service (using password – connected to azurekeyvault) needs to be like this:
"password": {
"secretName": "="
}
But for the secret type (from azure keyvault) for storage linked service, it has to be like this:
"servicePrincipalCredential": {
"secretName": "="
}
And then these args can be passed directly from azure keyvault if variable groups are connected to keyvault. This solves the problem we were facing.

APIM: Retrieving policy XML from Azure Blob storage within an Azure DevOps CD pipeline fails like getting an error like The provided link ismalformed

APIM: I am Retrieving policy XML from Azure Blob storage within an Azure DevOps CD pipeline fails like getting an error like The provided link is mal formed.
Can any one help me on this how to resolve this
The mentioned error occurs usually when wrong extension to reference the XML file with the policy definition.
Below is the sample how it looks like:
"properties": {
"value": "[concat(parameters('storageAccount'), '/', 'policies.json', parameters('storageAccountSASToken'))]",
"format": "rawxml-link"
}
As DeepDave suggested check whether you are using correct extension.

CI/CD ADF Synapse - Modify URL in Key Vault Linked service

We use Synapse git Integration to deploy artifacts such as linked services generated by a Data Warehouse automation tool (JSON files)
It is different then deploying ARM template in ADF.
We created one Azure Key Vault (AKV) per environment so we do have an Azure Key Vault LinkedService in each environment and the linked services has the same name. But each AKV as his own URL so we need to change the URL in the deployed linked services during the CI/CD process.
I read this https://learn.microsoft.com/en-us/azure/synapse-analytics/cicd/continuous-integration-deployment#use-custom-parameters-of-the-workspace-template
I think I need to create a template to change "Microsoft.Synapse/workspaces/linkedServices"
But I didn't find any example on how to modify the KV url parameters.
Here is the linked services I want to modify,https://myKeyVaultDev.vault.azure.net as to be changed when deploying
{
"name": "myKeyVault",
"properties": {
"type": "AzureKeyVault",
"typeProperties": {
"baseUrl": "https://myKeyVaultDev.vault.azure.net"
}
}
}
Not much familiar with the ci/cd and azure devOps yet, but still I need to do it...
I have done this using Azure Devops. When you create the Release pipeline within Azure Devops, one of the options is to "override parameters". at this point you can specify the name of the keyvault and the corresponding value. The corresponding value is configured in a pipeline variable set - which itself can come from the same keyvault.
You don't need to create the template. Synapse already does that and stores it in the publish branch (“workspace_publish”). If you look in that branch you will see the template along with the available parameters that you can override.
More info is available here:
https://www.drware.com/how-to-use-ci-cd-integration-to-automate-the-deploy-of-a-synapse-workspace-to-multiple-environments/
https://techcommunity.microsoft.com/t5/data-architecture-blog/ci-cd-in-azure-synapse-analytics-part-1/ba-p/1964172
From the Azure Key Vault side of things, I believe you're right - you have change the Linked Services section within the template to point to the correct Key Vault base URL.
Azure Key Vault linked service
I don't know if you still are looking for the solution.
In order to parametrize linked service property and specially AKV reference, I think you should modify the template-parameters-definition.json, and add the following section:
"Microsoft.Synapse/workspaces/linkedServices":
{ "*":
{ "properties":
{ "typeProperties":
{ "baseUrl": "|:-connectionString:secureString" }
}
}
}
This will create a parameter for each linked service. The next step is to overrideParameters on SynapseWorkspaceDeployment task on Azure Devops.

azure devops for ADF and databricks

I am trying to create an azure ci/cd pipeline for my azure data factory in which I have used databricks notebook. Pipeline got created successfully with the ARM template for ADF but I am not able to see any override parameter for databricks workspace URL, that's why i got the same databricks URL in my dev and prod environment.
Can anyone help me to set databricks workspace URL for Dev and prod dynamically?
For anyone facing the same challenge, I just added this code to my arm-template-parameters-definition.json:
"AzureDatabricks": {
"properties": {
"typeProperties": {
"domain": "=",
"existingClusterId":"=",
"accessToken": {
"secretName": "="
}
}
}
}
It will make the parameters explicit to be overriden.
If you are using the default template provided by Microsoft, I inserted the code just under the "ODBC" section factories/linkedServices.
you need to create a token in qa and prod and use that in ur ci cd pipeline..tokens are unique all
over and automatically linked to respective service