简体   繁体   中英

Taking a FQDN parameter string and chunking it up to use in a variable (Azure ARM Template)

I am creating a Azure ARM template for deploying a number if VMs in to an existing Active Directory. I am using jsonaddomainextension to do the AD join part of the deployment and I'd like specify a particular OU path for the computer object. jsonaddomainextension has a parameter for doing this but it requires a fully constructed OU path. As this template is being deployed by users that aren't AD literate and asking them to put the right OU path in will probably end in tears (mine probably).

One of the parameters the user does need to input is the FQDN of the domain.

       "Domain Name": {
        "defaultValue": "DOMAIN.CO.UK",
        "type": "string",
        "metadata": {
            "description": "Enter domain name"
        }

What I'd like to do is grab this string and use it to build a variable that I can pass to jsonaddomainextension in the OU format "OU=Servers,DC=DOMAIN,DC=CO,DC=UK". (The server container is always the same name). This is where I've come unstuck/run out of skill and need some help.

First off is is possible? any hints/tips on how I would do this would be gratefully received.

you can use string manipulation functions for that, something like this:

"modifiedstring": "[replace(parameters('domainname'), '.', ',DC=)]"
"oupath": "[concat('OU=Servers,DC=', variables('modifiedstring'))]"

this will result in replacing all dots with ,DC= and concatenating the result with the OU=Servers,DC= prefix. and then you can use the result as:

"property": "[variables('oupath')]"

Reference: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-functions-string

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM