I’ve got a number of Azure objects that I’d like to create during a deployment. These include Azure Service Bus topics, DocumentDB collections, and Azure Scheduler jobs, all of which are not able to be created using the Azure PowerShell cmdlets or using Azure Resource Manager templates. So, I’ve been thinking about other ways of doing this within my deployment from Octopus.
I’ve been experimenting with using a scriptcs script, in combination with the references to the Azure SDK libraries that I’d need to use for these tasks. This seemed like a nice option, but after spending several hours trying to just get a scriptcs script to even run locally against the Azure SDK, I’ve been pretty frustrated. I haven’t been able to reference the SDK libraries/NuGet packages successfully from scriptcs. If I try to use the scriptcs package installer it fails with error 1 below. If I manually reference the DLL files I get error 2 below, seemingly because the scriptcs script is executing on version 4.0 of the framework rather than 4.5/4.6. So, I’m not sure if it’s even possible to interact with the Azure SDK libraries using scriptcs.
A second option I’ve considered, but haven’t yet tried, is to use PowerShell to create the .NET objects I need, by using PowerShell’s [System.Reflection.Assembly]::LoadFrom(...)
capability.
A third option is to use the Azure REST API directly, rather than the SDK. I could then call it from a PowerShell script like this one. This will require a lot of work to get the actual calls and responses working though, and I don’t know if it’s worth it.
A fourth option is to write a console app in C#, and then have a script just execute that somehow. I’d really like to find a nicer way of making this work though.
Are there any options I’m missing? Thanks!
Error 1:
ERROR: Error installing package. [NuGetVersionNotSatisfiedException] The 'System.Net.Http 4.0.0' package requires NuGet client version '3.0' or above, but the current NuGet version is '2.8.60717.93'.
Error 2:
ERROR: Script compilation failed. [CompilationErrorException] C:\Temp\Script\mytest.csx(15,37): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.