Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#I @"..\packages\arm-deploy"
#I @"..\packages\arm-deploy\Newtonsoft.Json\lib\net45"
#r @"..\packages\arm-deploy\fake\tools\FakeLib.dll"
#load @"..\.paket\load\net452\arm-deploy\arm-deploy.group.fsx"
#load @"..\paket-files\arm-deploy\CompositionalIT\fshelpers\src\FsHelpers\ArmHelper\ArmHelper.fsx"
open Cit.Helpers.Arm
open Fake
open Fake.EnvironmentHelper
open Fake.TraceHelper
open System
open System.IO
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let mutable azure = None
Target "AzureAuthentication" <| fun _ ->
tracefn "Authenticating with Azure..."
let azureCredentials =
{ ClientId = getBuildParam "ClientId" |> Guid
ClientSecret = getBuildParam "ClientSecret"
TenantId = getBuildParam "TenantId" |> Guid }
let subscriptionId = getBuildParam "SubscriptionId" |> Guid
azure <- Some(authenticate azureCredentials subscriptionId)
Target "CreateResourceGroup" <| fun _ ->
let resourceGroup = getBuildParam "ResourceGroup"
let armTemplate = getBuildParam "ArmTemplate"
let outputs =
let deployment =
tracefn "Deploying template '%s' to resource group '%s'..." armTemplate resourceGroup
{ DeploymentName =
getBuildParamOrDefault "BUILD_BUILDNUMBER" (sprintf "LOCAL-%s" (getMachineEnvironment()).MachineName)
|> fun buildNumber -> buildNumber.Replace(" ", "_")
ResourceGroup = Existing resourceGroup
ArmTemplate = File.ReadAllText armTemplate
Parameters = [ "storageAccountName", getBuildParam "StorageAccountName" ]
DeploymentMode = Incremental }
deployment
|> deployWithProgress azure.Value
|> Seq.choose(function
| DeploymentInProgress (state, operations) -> tracefn "State is %s, completed %d operations." state operations; None
| DeploymentError (statusCode, message) -> traceError <| sprintf "DEPLOYMENT ERROR: %s - '%s'" statusCode message; None
| DeploymentCompleted outputs -> Some outputs)
|> Seq.head
let storageAccountKey = outputs.TryFind "storageAccountKey"
tracefn "Done! Storage account key is %A" storageAccountKey
// Build order
"AzureAuthentication"
==> "CreateResourceGroup"
// Start build
RunTargetOrDefault "CreateResourceGroup"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.