2

I have searched and read the documentation of Resource Management Template, but i couldn't find any information over Environment variables. I tried to define 2 environment variables in a variable object, but it didn't work.

variables": {
    "mailPass": "TYUl5491",
    "SlackToken": "hrtu-12546233785-55454578422-56454412348-87845155121ht5621552521er55547123"
  }

Is there any way to define environment variables in an Azure Resource Management Template and then use it for the web app or api app?

Pythonist
  • 115
  • 2
  • 12

1 Answers1

3

Yes, for a WebApp you can do that, here's the snippet of a full WebApp resource, replace values and names with something you need:

{
    "apiVersion": "2015-08-01",
    "name": "[parameters('siteName')]",
    "type": "Microsoft.Web/sites",
    "location": "[parameters('location')]",
    "properties": {
        "serverFarmId": "[parameters('hostingPlanName')]",
        "siteConfig": {
            "appSettings": [
                {
                    "name": "storageKey", # REPLACE ME
                    "value": "[listKeys(variables('storageid'),'2015-06-15').key1]" # REPLACE ME
                },
                {
                    "name": "storageAccount", # REPLACE ME
                    "value": "[parameters('storageAccountName')]" # REPLACE ME
                }
            ]
        }
    }
}
4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • Thanx @4c74356b41. Can i assign to a reference too? I mean an environment variable to a DocumentDB(MongoDB) connection string? – Pythonist Mar 30 '17 at 18:25
  • Thanx. How can i do that? "value": "[listKeys(variables('CONNECTION STRING'),'2015-06-15').key1]" ? I couldn't find its reference. – Pythonist Mar 30 '17 at 18:37
  • See also: [Retrieve the connection string of an SQL Azure database that is linked to a Windows Azure Web Site with C#.NET](http://stackoverflow.com/questions/20507956/retrieve-the-connection-string-of-an-sql-azure-database-that-is-linked-to-a-wind) – Miha Pirnat Apr 12 '17 at 09:31