Cloning an Azure resource group using Deployment Details? - azure

I am trying to replicate an existing Azure resource group using arm templates from the automation script section but running into a warning message about 10 resources types cannot be exported yet. One being Azure data factory. After searching online I found that templates for some resource types are not yet available. While looking at the Deployment section in my resource group, I am able to see a deployment details download link for each resource.
Can those be used to recreate each resource into a new resource group? Or is my best bet downloading the template from the automation script section and manually adding the resources for which the template are not yet available?
Any help would be appreciated.
Some of the warnings I got:
ResourceTypeSchemaNotFound:
***The schema of resource type 'Microsoft.DataFactory/dataFactories' is not available. Resources of this type will not be exported to the
template. (Code: ResourceTypeSchemaNotFound, Target:
Microsoft.DataFactory/dataFactories
ExportTemplateProviderError: all related to sql server
***Could not get resources of the type 'Microsoft.Sql/servers/connectionPolicies'. Resources of this type
will not be exported. (Code: ExportTemplateProviderError, Target:
Microsoft.Sql/servers/connectionPolicies)
***Could not get resources of the type 'Microsoft.Sql/servers/backupLongTermRetentionVaults'
***Could not get resources of the type 'Microsoft.Sql/servers/extendedAuditingSettings'.

The Azure resource group ARM templates from the automation script section are not as comprehensive as they should probably be. For example, it is quite possible to deploy a Data Factory instance from ARM. It provides a reasonable starting point but you will find resources that don't deploy as well as a lot of superfluous cruft.
The approach I take is to start from a clean template in Visual Studio and then construct a project from a blank template or quick-start, then refer to the template documentation and build up from scratch, using your exported ARM template from your resource group to help work out how it should look. This results in a nice clean reusable template project.
Unfortunately I have not found an better way yet.

Related

Filter verbose Azure ARM template

Exported Azure ARM template contains a lot's of useless information, let's say snapshots. I would like export actual resource definitions only.
Is it possible to filter unnecessary items out? I would like to convert this template to Bicep (to deploy all the resources into an another subscription) and now I have to clear manually all the unused items from the exported ARM template.
Thank you Gopa. Posting your suggestion as an answer to help other community members.
Exporting an ARM template from the resource group or resource will give you a template that is a snapshot of the current properties so it includes all the properties which were changed after the initial deployment.
You can also try exporting templates from the deployment history too which will give you an option to export your initial version without the changes you made after each deployment.
You can maintain all resources in source control as ARM templates and use CI/CD to deploy, whenever there is a change, so you can have our latest version of ARM templates and use it to build up a new environment when a need comes.
You can export the template that was used to deploy existing resources. The template you get is exactly the one that was used for deployment.
Export template after deployment
Select the resource group you want to export.
Select the link under Deployments.
Select one of the deployments from the deployment history.
Select Template. The template used for this deployment is displayed, and is available for download.

How do i export an ARM template correctly from Azure?

I have already installed my azure environment with a VM, a storage account and a data base server, and it works fine, but now i want to export the ARM template in order to automate the whole proccess to my customers. The problem is that when exporting this message shows up:
error
So the question is how do i export an ARM template correctly from Azure with all my resources without having to do much fixing my final template?
that is expected. some resource types cannot be exported. you'd have to take a look at the api definition and use that to export those (say at resources.azure.com)
Simple: use bicep. Azure Resource Manager's transpiler (it's a sweeter syntax that solves your needs)
In Bicep the directive you're looking for in your Azure Resource Manager "ARM" template is keyword "existing"
https://github.com/Azure/bicep/blob/main/docs/tutorial/05-loops-conditions-existing.md
keyword "existing" lets you reference a resource without a complete definition.
Otherwise you need to provide the entire ARM definition for the object.
Export failures per resource type occur when a given resource types schema is not available. We are looking into how we can autogenerate schemas for Azure resource providers and onboarding them to this new process, improving the overall success of the Export Template API.

Update WadCfg "only" of existing Azure Service Fabric cluster?

I want to monitor Perfomance metrics of a existing Service Fabric Cluster.
Here is the link of Performance metrics -
https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-diagnostics-event-generation-perf
I went through this Microsoft documentation -
https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-diagnostics-perf-wad
My problem is, The ARM template I downloaded during Service Fabric creation time is quite big and contains lot of params and I don't have the template-params file. I think it is possible to build the params file but it will be time consuming.
Is it possible to download template and template-params file of
existing service fabric cluster ?
If no, Is it possible to just update the "WadCfg" section to add new
performance counters ?
Your can export your entire resource group with all definitions and parameters, there you can find all parameters(as default parameters) for the resources deployed in the resource group. I've never done for SF cluster, but a quick look to an existing resource group I have I could see the cluster definition included.
This link explain how: https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-export-template
In Summary:
Find the resource group where your cluster is deployed
Open the resource group and navigate to 'Automation Scripts'
Click 'Download' on top bar
Open the ARM template with all definitions
Make the modifications and save
Publish the updates
1:
2:
You could also add it to a library and deploy from there, as guided in the link above.
From the docs: Not all resource types support the export template function. To resolve this issue, manually add the missing resources back into your template.
To be honest, I've never deployed this way other than test environments, so I am not sure if it is safe for production.

How can you get the Azure automation script for just a single service?

How can you get the Azure automation script for just a single service?
In this case I've selected an App Service Plan, but when I click on it's "Automation script" in the Azure Portal, I get the script for everything (minus the various resource types "that cannot be exported yet" )
Unfortunately, export function only allows to export everything in the resource group, so you get an ARM template that represents the resource group.
If you want to get an ARM template solely for that resource, please deploy it into it's own resource group and then use the Automation script option.
Alternatively, you can use armviz to get a visual representation. When you click on a particular element, it will take you directly to that object in the arm template. Not exactly what you are looking for, but might give you enough.
You can't export just a single resource if there are multiple resources in the resource group, but maybe visual studio can help.
If you export the template and load it in VS as an arm template project, you can easily delete the other resources from the sidebar and leave just the one you need. You might also need to clean up the vars/params though.

Azure Resource Manager Template parameters

I am trying my hands on over Azure Resource manager templates.
So for making any new resource I am trying to find out which all parameters are required and if they are mandatory or optional. But couldn't get any documentation for same.
I am looking for documentation which is somewhat similar to AWS. To get better in sites about the resources.
Thanks in advance!!
EDIT
I am not looking for parameters in general which are passed to the template. What I want is the resources parameters. The parameters which are given under the properties tag of every resource
Example-
In the below resource "virtualNetworks" there are resource parameters like addressSpace, subnets.
virtualNetworks
This should help you.
It is the schema for deployment templates. Within it, there are schemas for every type of resource that can be put into an arm template. For example, if we look at the schema for Virtual Machines, it contains all the available properties, profiles, extensions, what is required or not, etc.
However, it shouldn't be necessary for you to really look at this and learn it. When you are creating your arm template in visual studio, intellisense should kick in and show you whether what you are putting in the template is valid or not. For example, here I am editing the properties of a public IP, and it shows me what the available properties to add are.
you are right, there is a lack of documentation for resources and required parameters.
My advice is:
Check the Azure-Quickstart Templates, more than enough examples: Quickstart Templates
Since some days you can export ARM Templates from the Azure Portal. So create your resource in portal and export the Templates & Parameters: Microsoft Blog
Check the resource Explorer: Resource Explorer

Resources