Monday 10 December 2012

Cloud "Forecast"?


It's worth re-capping a couple of points from my previous post talking about operational cost reduction using Windows Azure. A key benefit of using the cloud is the ability to quickly and easily tear down environments, this includes test environments. If you are not using a test environment, then simply delete it and recreate it later when you need it. This can give you very large cost reductions.

With this in mind, I have created an application that will automatically tear down (or create) cloud resources on a schedule. The application can be run as a console or installed as a windows service.

At the moment you can:
  • Delete "Hosted Services" on a schedule.
  • Create "Hosted Services" on a schedule.
  • Delete Storage Tables on a schedule.
  • Delete Storage Blob Containers on a schedule.
Additional features will be added in time.

You can see the GitHub project here: https://github.com/StealFocus/Forecast

An example configuration is as follows:


  <stealFocusForecastConfiguration 
    xmlns="urn:StealFocus.Forecast.Configuration">
    <scheduleDefinitions>
      <scheduleDefinition name="MorningOutOfHours">
        <days>
          <day name="Monday" startTime="00:00:00" endTime="07:59:59" />
          <day name="Tuesday" startTime="00:00:00" endTime="07:59:59" />
          <day name="Wednesday" startTime="00:00:00" endTime="07:59:59" />
          <day name="Thursday" startTime="00:00:00" endTime="07:59:59" />
          <day name="Friday" startTime="00:00:00" endTime="07:59:59" />
        </days>
      </scheduleDefinition>
      <scheduleDefinition name="BusinessHours">
        <days>
          <day name="Monday" startTime="08:00:00" endTime="18:00:00" />
          <day name="Tuesday" startTime="08:00:00" endTime="18:00:00" />
          <day name="Wednesday" startTime="08:00:00" endTime="18:00:00" />
          <day name="Thursday" startTime="08:00:00" endTime="18:00:00" />
          <day name="Friday" startTime="08:00:00" endTime="18:00:00" />
        </days>
      </scheduleDefinition>
      <scheduleDefinition name="EveningOutOfHours">
        <days>
          <day name="Monday" startTime="18:00:01" endTime="23:59:59" />
          <day name="Tuesday" startTime="18:00:01" endTime="23:59:59" />
          <day name="Wednesday" startTime="18:00:01" endTime="23:59:59" />
          <day name="Thursday" startTime="18:00:01" endTime="23:59:59" />
          <day name="Friday" startTime="18:00:01" endTime="23:59:59" />
        </days>
      </scheduleDefinition>
      <scheduleDefinition name="Weekend">
        <days>
          <day name="Saturday" startTime="00:00:00" endTime="23:59:59" />
          <day name="Sunday" startTime="00:00:00" endTime="23:59:59" />
        </days>
      </scheduleDefinition>
    </scheduleDefinitions>
    <windowsAzure>
      <subscriptions>
        <subscription
          id="myArbitraryAzureSubscriptionName"
          subscriptionId="GUID"
          certificateThumbprint="0000000000000000000000000000000000000000" />
      </subscriptions>
      <hostedService>
        <packages>
          <package
            id="myArbitraryPackageName"
            storageAccountName="myAzureStorageAccountName"
            containerName="MyContainer"
            blobName="MyPackage.cspkg" />
        </packages>
        <deploymentDeletes>
          <deploymentDelete
            serviceName="myAzureServiceName"
            pollingIntervalInMinutes="10"
            subscriptionConfigurationId="myArbitraryAzureSubscriptionName">
            <deploymentSlots>
              <deploymentSlot name="Staging" />
              <deploymentSlot name="Production" />
            </deploymentSlots>
            <schedules>
              <schedule scheduleDefinitionName="MorningOutOfHours" />
              <schedule scheduleDefinitionName="EveningOutOfHours" />
              <schedule scheduleDefinitionName="Weekend" />
            </schedules>
          </deploymentDelete>
        </deploymentDeletes>
        <deploymentCreates>
          <deploymentCreate
            subscriptionConfigurationId="myArbitraryAzureSubscriptionName"
            windowsAzurePackageId="myArbitraryPackageName"
            serviceName="myAzureServiceName"
            deploymentName="MyName"
            deploymentLabel="MyLabel"
            deploymentSlot="Production"
            packageConfigurationFilePath="C:\PathTo\MyPackageConfiguration.cscfg"
            treatWarningsAsError="true"
            startDeployment="true"
            pollingIntervalInMinutes="10">
            <schedules>
              <schedule scheduleDefinitionName="BusinessHours" />
            </schedules>
          </deploymentCreate>
        </deploymentCreates>
      </hostedService>
      <storageService>
        <storageAccounts>
          <storageAccount
            storageAccountName="myStorageAccountName"
            storageAccountKey="myStorageAccountKey" />
        </storageAccounts>
        <tableDeletes>
          <tableDelete
            id="myArbitraryTableDeleteId"
            storageAccountName="myStorageAccountName"
            pollingIntervalInMinutes="60">
            <storageTables>
              <storageTable tableName="myAzureTableName1" />
              <storageTable tableName="myAzureTableName2" />
            </storageTables>
            <schedules>
              <schedule scheduleDefinitionName="MorningOutOfHours" />
              <schedule scheduleDefinitionName="EveningOutOfHours" />
              <schedule scheduleDefinitionName="Weekend" />
            </schedules>
          </tableDelete>
        </tableDeletes>
        <blobContainerDeletes>
          <blobContainerDelete
            id="myArbitraryBlobContainerDeleteId"
            storageAccountName="myStorageAccountName"
            pollingIntervalInMinutes="60">
            <blobContainers>
              <blobContainer blobContainerName="myAzureBlobContainerName1" />
              <blobContainer blobContainerName="myAzureBlobContainerName2" />
            </blobContainers>
            <schedules>
              <schedule scheduleDefinitionName="MorningOutOfHours" />
              <schedule scheduleDefinitionName="EveningOutOfHours" />
              <schedule scheduleDefinitionName="Weekend" />
            </schedules>
          </blobContainerDelete>
        </blobContainerDeletes>
      </storageService>
    </windowsAzure>
  </stealFocusForecastConfiguration>


0 comments:

About Me