Azure ARM Template - List resources - azure

Is it possible and if yes how, to list available (previously created) VMs, so that I can select my "target" from dropdown during the deployment process from my ARM template.

no, this is not possible, you have to use other means (powershell\cli\rest api\sdk) to find that information and pass it to the template.
if your VM list never changes - you can hardcode it as allowedValues for the parameter. that will achieve what you want, but you'll have to update those everytime you create\delete\move vm.

Related

Azure ARM - Baseline resources with ARM template

I have created an ARM template for deploying resources into an Azure Resource Group. Is there any way I could use the same ARM template to perform automated "Baseline-Checks" in order to check if the resources have been changed in any way?
Are you just trying to determine if the state of the resources in Azure have "drifted" from the state declared in the template? If so you can use the what-if api and parse the results from that to see if something has changed.
https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/deploy-what-if?tabs=azure-powershell
If you want to prevent drift from occurring, you can lock the resources to prevent changes.
https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/lock-resources?tabs=json
You can perform baseline checks by using ARM template but you need to
create individual template for each resource group in incremental
mode and when there is any changes in the resource it will
automatically updated in the template and by that way you can perform
baseline checks
Here is the documentation which helps in creating
ARM template.

Is it possible to update the assigned Azure DSC configuration to a VM via ARM Template?

I need to change the Azure DSC configuration that has been previously assigned to a VM.
I'm trying to do this programatically because it's part of an automation I'm developing and because of this, I'm using ARM Templates.
However, redeploying the same VM DSC extension by ARM Template results in an error stating a VM can't have two of the same extensions, which sounds logical.
What I want to know if it's possible to, by ARM Template, "update" or "modify" the current extension with just one setting changed: The configuration name.
Is this possible?
Sure - you can update the existing VM extension by providing new configuration in your ARM template. As you have found out, you cannot use a different name for the extension - that would result in two VM extensions of the same type on the VM. Instead, you need to reuse the same name of the existing VM extension when performing the update.

Azure ARM Template - is it possible to get existing resources names to specify them as parameters or variables inside new ARM deployment?

My issue is related to Azure ARM
I want to populate the parameters allowed list with values, taken from the current resource group.
To be clear - I want to place a virtual machine to virtual network subnet, but I don't want to enter vNet name manually. I already have find a way to get resourcegroup id, resource group name, subscription id but it seems what there is no way to get a list of objects from here - only if I know resource name, please tell me - it is possible at all?
No, this is not possible at all with ARM Templates. What you can do - you can use powershell script that would pull those values and the user will pick one of those values before the deployment (using Out-GridView, for example).

Updating Set of Values in ARM Templates Automatically

I have an ARM template, which I will be using it to deploy resources (Mentioned as in Azure Portal) via Azure DevOps Pipeline. These ARM templates were created using my Dev Subscription. If I need to use this same ARM template to move to production, I need to manually update the subscription id etc in the ARM template and then run the respective pipelines. Is there any way to automate this manual updation process in ARM template.
I have tried using File Transform Agent job available under Azure DevOps Release pipeline. But since the values are available inside nested loops of ARM templates, it failed. Is there any PowerShell script that will be suitable for this process of updating values.
I don't want to manually update the ids under the ARM Template. Instead, I want to update it automatically.
Set Json Property task might help to set the property with specific value.
First in the marketplace search for "set Json property" task and install it for your organization.
Then you can set the property path and the value accordingly. check here for detail usage
Instead of hard coding in ARM templates you can use parameters file. For dev and prod you can have separate files and while deploying pass ARM Template along with parameter file whichever is required.
You can use AKV (Azure Key Vault) to access your subscription details in parameter file
subscription().subscriptionid will get you the details

Working with azure templates incrementaly

So I have this template that I've used to create my resource group. We are in the middle of development process, so it is pretty usual to add different resources from day to day.
How can I run the template to just add the ones that I am missing?
I've tried to deploy my template to my existing resource group, but I guess it just thinks that I want to create another set of resources.
What should I do?
ARM Templates are idempotent by default, so if you add resources to the template without changing anything else in it, it will just create\add new resources to your resource group. So that behavior is be default.
As for the parameters, it cannot magically infer the names (or anything) of things that you want to pass. You can either reuse existing deployments (it will prepopulate all the parameters), create a script that will pass in parameters, create a parameters file to pass in to the template.
Reference:
https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-deploy

Resources