Skip to content

Instantly share code, notes, and snippets.

@chgeuer
Created January 22, 2015 11:20
Show Gist options
  • Save chgeuer/c53d0907fc01ffd6a4b4 to your computer and use it in GitHub Desktop.
Save chgeuer/c53d0907fc01ffd6a4b4 to your computer and use it in GitHub Desktop.
Func<string, Task<bool>> CheckNameAvailabilityAsync = async (cloudServiceName) =>
{
var computeManagementClient = new Microsoft.WindowsAzure.Management.Compute.ComputeManagementClient( // Microsoft.WindowsAzure.Management.Compute.8.0.0
new Microsoft.Azure.CertificateCloudCredentials( // Microsoft.Azure.Common.2.0.1
subscriptionID, subscriptionManagementCertificateThumbprint.FindX509CertificateByThumbprint(storeLocation)));
var result = await computeManagementClient.HostedServices.CheckNameAvailabilityAsync(cloudServiceName, cancellationToken);
return result.IsAvailable;
};
Func<string, string> CreateCloudServiceName = (prefix) =>
{
return string.Join("-", prefix, System.DateTime.UtcNow.ToString("yyMMddhhmmssfff"), Guid.NewGuid().ToString());
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment