Concat arguments - azure

I have a couple of questions in the following line ARM template code
"variables": {
"apiVersion": "2016-06-01",
"SharedTemplateSAS": "[concat('?',split(deployment().properties.templateLink.uri,'?')[1])]",
What is the argument '?' going to be ?
Is the properties.templateLink.uri dependent on the TemplateLink URI? (I want to use templatespec and refer to linked templates by relative path)
Finally, what is the line doing exactly?

"SharedTemplateSAS":
"[concat('?',split(deployment().properties.templateLink.uri,'?')1)]",
What is the argument '?' going to be ? Is the
properties.templateLink.uri dependent on the TemplateLink URI? (I want
to use templatespec and refer to linked templates by relative path)
Looking at the sample examples in the git Hub for linked templates, the template link uri property is used in the linked templates inorder to get the uri of the childtemplate which contains the information about the resources that are going to be deployed using those linked templates.
Based on the Azure documentation, the SharedTemplateSAS variable parameters will be below format
uri": "[concat(uri(deployment().properties.templateLink.uri, 'helloworld.json'), parameters('containerSasToken'))]",
Wherein helloworld.json is the linked template which is stored in the storage account inorder to avoid the public access to that template.
if you are working with Template spec securely,template spec stores the main template and its linked templates as a resource in your Azure subscription. You use Azure RBAC to grant access to users who need to deploy the template.
You can refer this documentation, if you want to create a template spec with link template & to deploy template spec as linked template.

Related

Azure resource manager template deployments - Using _artifactsLocation and _artifactsLocationSasToken

Where and how to use artifactsLocation and _artifactsLocationSasToken in Arm template deployments. Are these used only for nested deployments.
Can we use these for custom VM extension of the Virtual machine as part of post provisioning activity, after VM is built or should the extension be added as part of the VM build deployment template only.
VM Custom script extension - (Initialize and format data drives, Mount file shares for instance)
Azure quick start templates, have the parameter values for these as default for artifactsLocation and type securestring for _artifactsLocationSasToken. How these values are populated in the ARM deployment runtime.
It would be great if someone can provide documentation around the same / step by step process or share an existing working custom script extension template.
There's nothing inherent in the platform that makes _artifactsLocation and _artifactsLocationSasToken special... it's just a pattern (well used) that has developed for staging artifacts needed for a deployment. The pattern is to stage all artifacts together and then use the uri of the main template as a relative location. The defaultValue generally used for _artifactsLocation is:
"defaultValue": "[deployment().properties.templateLink.uri]"
The deployment() function is inherent and contains the uri passed in for the main template.
That said, you can use those values anyway you see fit and the primary use case is for retrieving any artifact needed by any resource. For example:
Custom Script Extension
https://github.com/Azure/azure-quickstart-templates/blob/master/demos/vm-winrm-windows/azuredeploy.json#L256-L259
MSDeploy Packages for WebApps
https://github.com/Azure/azure-quickstart-templates/blob/master/demos/private-endpoint-sql-from-appservice/azuredeploy.json#L277
DSC Configuration Modules
https://github.com/Azure/azure-quickstart-templates/blob/master/demos/iis-2vm-sql-1vm/azuredeploy.json#L585
etc, etc...
That help?

Use of generators under metadata in ARM Templates

What is the use of the highlighted part in the Azure ARM Templates' JSON structure? Where does the resource use it?
Resource manager ignores the metadata at the time of deployment. This is just for you to share the more information about the template and its resources with other developers.
From this link:
You can add a metadata object almost anywhere in your template.
Resource Manager ignores the object, but your JSON editor may warn you
that the property isn't valid. In the object, define the properties
you need.
A caveat here is when you define metadata with description property for your template parameters. When you deploy the template through Azure Portal, the description is shown as a tool tip for that parameter.

Azure portal Template Deployment not supporting Keyvault references

I have a set of resources and want to deploy them using Template Deployment feature in Azure portal. In my parameters file, I have few references to parameters in Key Vault as mentioned here. When deploying the template in Azure portal (clicking on Deploy a custom template) and supplying these values, the portal still asks for these parameters explicitly which I definitely cannot provide in plain text.
When using the same resources.json and parameters.json file in powershell, it works fine.Is the feature of KeyVault references currently not supported in Template Deployment done through portal ?
Yes, this is the case, but you can workaround that by wrapping you template with another template and that template will "get" the reference and pass it to the actual template.
reference: https://github.com/4c74356b41/bbbb-is-the-word/blob/master/_arm/parent.json#L151

Azure Template reference function does not work for existing resource (not in template)

trying to use reference function in my ARM template for a resource that is already existing, but not included in my template. This does not seem to work. Is there some way to do this?
In particular, I'm deploy a new SQL database to an existing SQL server, along with a new webapp. In the web app, I'm trying to set connection string using
reference(concat('Microsoft.Sql/servers/', variables('sqlserverName'))).fullyQualifiedDomainName
but this doesnot work - says the resource is not available/included.
For reference function to work on existing resources you need to pass in the API versiĆ³n. Documentation.
apiVersion - API version of the specified resource. Include this parameter when the resource is not provisioned within same template. Typically, in the format, yyyy-mm-dd.
reference(parameters('storageAccountName'), '2016-12-01')

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