{"id":2455,"date":"2018-06-25T09:45:10","date_gmt":"2018-06-25T08:45:10","guid":{"rendered":"http:\/\/blog.repsaj.nl\/?p=2455"},"modified":"2018-06-22T14:14:41","modified_gmt":"2018-06-22T13:14:41","slug":"azure-what-outputs-can-i-use-for-my-arm-templates","status":"publish","type":"post","link":"http:\/\/blog.repsaj.nl\/index.php\/2018\/06\/azure-what-outputs-can-i-use-for-my-arm-templates\/","title":{"rendered":"[Azure] What outputs can I use for my ARM templates?"},"content":{"rendered":"<p>ARM templates are a good way of deploying your infrastructure to Azure as if it were code (it sort of is, actually). Basically you provide a JSON file along with a parameter file and Azure starts creating stuff for you. For more information on how this works (as that&#8217;s pretty well documented), check out <a href=\"https:\/\/docs.microsoft.com\/nl-nl\/azure\/azure-resource-manager\/\" target=\"_blank\" rel=\"noopener\">this link<\/a>.<\/p>\n<p>One of the options you have when using these templates, is using the\u00a0<strong>outputs<\/strong> section. The outputs section basically tells the deployment task to output some information, which you can then use for whatever purpose you need it. Simple example: suppose you&#8217;re deploying an application that relies on a service bus. You&#8217;ll need to deploy the bus first, and the application will require a connectionstring to figure out where the bus lives. Using outputs, you can do the following:<\/p>\n<ul>\n<li>Deploy the service bus, defining an output variable for the connectionstring<\/li>\n<li>Deploy the application, replacing a token in the configuration file with the actual connectionstring<\/li>\n<\/ul>\n<p>When you have a pipeline set-up in VSTS (or any other deployment tool), this is dead simple. The cool thing: you don&#8217;t have to worry about runtime configuration any more, as your pipeline will ensure everything is set-up in the right way. Nice, right?<\/p>\n<p>Here&#8217;s an example of an outputs section:<\/p>\n<pre class=\"lang:default decode:true\">  \"outputs\": {\r\n    \"NamespaceConnectionString\": {\r\n        \"type\": \"string\",\r\n        \"value\": \"[listkeys(variables('authRuleResourceId'), variables('sbVersion')).primaryConnectionString]\"\r\n    }\r\n  }<\/pre>\n<p>Working with these output, I was trying to figure out which outputs I could actually use. Some articles give examples of which you can copy stuff, but not all of them do so. In the above example,\u00a0<strong>.primaryConnectionString\u00a0<\/strong>is apparently a property you can use. So how do you know which properties there are!?<\/p>\n<p>The answer is one in the &#8220;duh&#8230;&#8221; category, but it took me some time to figure this out nonetheless. Basically, the resource you are creating determines the properties you can use. Every resource type has a corresponding\u00a0<strong>Get-AzureRm&lt;ResourceType&gt; <\/strong>Powershell cmdlet (or CLI, etc.). To find the type, simply check your template for the\u00a0<strong>&#8220;type&#8221;: &#8220;Microsoft.ServiceBus\/namespaces&#8221;\u00a0<\/strong>section. In this case it&#8217;s a servicebus namespace, so the corresponding cmdlet would be\u00a0<strong>Get-AzureRmServiceBusNamespace<\/strong>. Run that one and you have your list of properties to pick from, including the option to use a property of one of the child objects. Hope it helps!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ARM templates are a good way of deploying your infrastructure to Azure as if it were code (it sort of is, actually). Basically you provide a JSON file along with a parameter file and Azure starts creating stuff for you. For more information on how this works (as that&#8217;s pretty well documented), check out this<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[34],"tags":[78,201,202],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3KFR1-DB","_links":{"self":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts\/2455"}],"collection":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/comments?post=2455"}],"version-history":[{"count":0,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/posts\/2455\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/media?parent=2455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/categories?post=2455"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.repsaj.nl\/index.php\/wp-json\/wp\/v2\/tags?post=2455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}