<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Landing Zone on Niels Ophey</title><link>https://www.ophey.net/en/tags/landing-zone/</link><description>Recent content in Landing Zone on Niels Ophey</description><generator>Hugo</generator><language>en</language><lastBuildDate>Fri, 05 May 2023 17:00:37 +0200</lastBuildDate><atom:link href="https://www.ophey.net/en/tags/landing-zone/index.xml" rel="self" type="application/rss+xml"/><item><title>Bicep Module for an Anomaly Alert</title><link>https://www.ophey.net/en/blog/caf-bicep-anomalyalert/</link><pubDate>Fri, 05 May 2023 17:00:37 +0200</pubDate><guid>https://www.ophey.net/en/blog/caf-bicep-anomalyalert/</guid><description>&lt;p>In our &lt;a href="https://github.com/caf-expert/CAF-LandingZone-StarterKit">CAF Landing Zone Starter Kit&lt;/a>, the implementation of the Anomaly Alert on the subscription was missing until now. This is almost complete. Here is a possible implementation of the Anomaly Alert as a Bicep module.&lt;/p>
&lt;h2 id="anomaly-alert-bicep">Anomaly Alert Bicep&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bicep" data-lang="bicep">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">targetScope&lt;/span> = &lt;span style="color:#e6db74">&amp;#39;subscription&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>@&lt;span style="color:#a6e22e">description&lt;/span>(&lt;span style="color:#e6db74">&amp;#39;Name of the Anomaly Alert&amp;#39;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">param&lt;/span> aaName string = &lt;span style="color:#e6db74">&amp;#39;myAnomalyAlert&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>@&lt;span style="color:#a6e22e">description&lt;/span>(&lt;span style="color:#e6db74">&amp;#39;Display Name of the Anomaly Alert&amp;#39;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">param&lt;/span> aaDisplayName string = &lt;span style="color:#e6db74">&amp;#39;Anomaly Alert&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>@&lt;span style="color:#a6e22e">description&lt;/span>(&lt;span style="color:#e6db74">&amp;#39;Subject of the Anomaly Alert email notification&amp;#39;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">param&lt;/span> aaNotificationSubject string = &lt;span style="color:#e6db74">&amp;#39;Anomaly Alert detected for your Subscription&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>@&lt;span style="color:#a6e22e">description&lt;/span>(&lt;span style="color:#e6db74">&amp;#39;Email address to send the Anomaly Alert notification to&amp;#39;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">param&lt;/span> aaNotificationTo string
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>@&lt;span style="color:#a6e22e">description&lt;/span>(&lt;span style="color:#e6db74">&amp;#39;Message of the Anomaly Alert email notification&amp;#39;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">param&lt;/span> aaNotificationMessage string = &lt;span style="color:#e6db74">&amp;#39;The Anomaly Alert has been triggered for your Subscription &lt;/span>&lt;span style="color:#e6db74">${&lt;/span>&lt;span style="color:#a6e22e">subscription&lt;/span>().subscriptionId&lt;span style="color:#e6db74">}&lt;/span>&lt;span style="color:#e6db74">. Please check the Cost Management Dashboard for more details.&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>@&lt;span style="color:#a6e22e">description&lt;/span>(&lt;span style="color:#e6db74">&amp;#39;Start date of the Anomaly Alert (default: now)&amp;#39;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">param&lt;/span> aaStartDate string = &lt;span style="color:#a6e22e">utcNow&lt;/span>(&lt;span style="color:#e6db74">&amp;#39;u&amp;#39;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>@&lt;span style="color:#a6e22e">description&lt;/span>(&lt;span style="color:#e6db74">&amp;#39;End date of the Anomaly Alert (default: 1 year from now)&amp;#39;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">param&lt;/span> aaEndDate string = &lt;span style="color:#a6e22e">dateTimeAdd&lt;/span>(&lt;span style="color:#a6e22e">utcNow&lt;/span>(&lt;span style="color:#e6db74">&amp;#39;u&amp;#39;&lt;/span>), &lt;span style="color:#e6db74">&amp;#39;P1Y&amp;#39;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">// The kind of the Anomaly Alert must be &amp;#39;InsightAlert&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">var&lt;/span> aaKind = &lt;span style="color:#e6db74">&amp;#39;InsightAlert&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">resource&lt;/span> myAnomalyAlert &lt;span style="color:#e6db74">&amp;#39;Microsoft.CostManagement/scheduledActions@2022-10-01&amp;#39;&lt;/span> = {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> name: aaName
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> kind: aaKind
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> properties: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> displayName: aaDisplayName
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> scope: &lt;span style="color:#e6db74">&amp;#39;/subscriptions/&lt;/span>&lt;span style="color:#e6db74">${&lt;/span>&lt;span style="color:#a6e22e">subscription&lt;/span>().subscriptionId&lt;span style="color:#e6db74">}&lt;/span>&lt;span style="color:#e6db74">&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> notification: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> subject: aaNotificationSubject
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> to: [
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> aaNotificationTo
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> ]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> message: aaNotificationMessage
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> status: &lt;span style="color:#e6db74">&amp;#39;Enabled&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> viewId: &lt;span style="color:#a6e22e">resourceId&lt;/span>(&lt;span style="color:#e6db74">&amp;#39;Microsoft.CostManagement/views/&amp;#39;&lt;/span>,&lt;span style="color:#e6db74">&amp;#39;ms:DailyAnomalyByResourceGroup&amp;#39;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> schedule: {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> endDate: aaEndDate
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> frequency: &lt;span style="color:#e6db74">&amp;#39;Daily&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> startDate: aaStartDate
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="deploying-the-module">Deploying the Module&lt;/h2>
&lt;p>The module can be applied using the Azure CLI. The important thing is to verify that you are in the correct subscription first. Then the deployment is straightforward:&lt;/p></description></item></channel></rss>