We released 1.1 of the Azure Management Libraries for .NET. This release adds support for:
| Cosmos DB | Azure Container Service and Registry | Active Directory Graph |
https://github.com/azure/azure-sdk-for-net/tree/Fluent
Getting started
You can download 1.1 from:
Create a Cosmos DB with DocumentDB API
You can create a Cosmos DB account by using a define() … create() method chain.
var documentDBAccount = azure.DocumentDBAccounts.Define(docDBName)
.WithRegion(Region.USEast)
.WithNewResourceGroup(rgName)
.WithKind(DatabaseAccountKind.GlobalDocumentDB)
.WithSessionConsistency()
.WithWriteReplication(Region.USWest)
.WithReadReplication(Region.USCentral)
.Create();
In addition, you can:
- Create Cosmos DB with DocumentDB API and configure for high availability
- Create Cosmos DB with DocumentDB API and configure with eventual consistency
- Create Cosmos DB with DocumentDB API, configure for high availability and create a firewall to limit access from an approved set of IP addresses
- Create Cosmos DB with MongoDB API and get connection string
Create an Azure Container Registry
You can create an Azure Container Registry by using a define() … create() method chain.
var azureRegistry = azure.ContainerRegistries.Define("acrdemo")
.WithRegion(Region.USEast)
.WithNewResourceGroup(rgName)
.WithNewStorageAccount(saName)
.WithRegistryNameAsAdminUser()
.Create();
You can get Azure Container Registry credentials by using ListCredentials().
RegistryListCredentials acrCredentials = azureRegistry.ListCredentials();
Create an Azure Container Service with Kubernetes Orchestration
You can create an Azure Container Service by using a define() … create() method chain.
var azureContainerService = azure.ContainerServices.Define(acsName)
.WithRegion(Region.USEast)
.WithNewResourceGroup(rgName)
.WithKubernetesOrchestration()
.WithServicePrincipal(servicePrincipalClientId, servicePrincipalSecret)
.WithLinux()
.WithRootUsername(rootUserName)
.WithSshKey(sshPublicKey)
.WithMasterNodeCount(ContainerServiceMasterProfileCount.MIN)
.WithMasterLeafDomainLabel("dns-myK8S")
.DefineAgentPool("agentpool")
.WithVMCount(1)
.WithVMSize(ContainerServiceVMSizeTypes.StandardD1V2)
.WithLeafDomainLabel("dns-ap-myK8S")
.Attach()
.Create();
Create Service Principal with Subscription Access
You can create a service principal and assign it to a subscription with contributor role by using a define() … create() method chain.
var servicePrincipal = authenticated.ServicePrincipals.Define("spName")
.WithExistingApplication(activeDirectoryApplication)
// define credentials
.DefinePasswordCredential("ServicePrincipalAzureSample")
.WithPasswordValue("StrongPass!12")
.Attach()
// define certificate credentials
.DefineCertificateCredential("spcert")
.WithAsymmetricX509Certificate()
.WithPublicKey(File.ReadAllBytes(certificate.CerPath))
.WithDuration(TimeSpan.FromDays(7))
// export credentials to a file
.WithAuthFileToExport(new StreamWriter
(new FileStream(authFilePath, FileMode.OpenOrCreate)))
.WithPrivateKeyFile(certificate.PfxPath)
.WithPrivateKeyPassword(certPassword)
.Attach()
.WithNewRoleInSubscription(role, subscriptionId)
.Create();
Similarly, you can:
- Manage service principals
- Browse graph (users, groups and members) and managing roles
- Manage passwords
Try it
You can get more samples from GitHub. Give it a try and let us know what do you think by emailing us or commenting below.
