I host a WCF 4.5 service in azure WebRole and I use Azure ACS Service Identities to manage my wcf users (active authentication). this model is accepted for me because we have a limited number of users
Now I want to know How can I manage (Create/Read/Update/Delete) ACS Service Identities programmatically via C# code.
Take a look at the ACS Management Service API which has ServiceIdentity
management.
The management endpoint is located here:
https://NAMESPACE.accesscontrol.windows.net/v2/mgmt/service
You can leverage this ACS Management service to create new ServiceIdentities
string name = "SampleServiceIdentity";
string password = "SampleServiceIdentityPassword";
ServiceIdentity sid = new ServiceIdentity()
{
Name = name
};
DateTime startDate, endDate;
startDate = DateTime.UtcNow;
endDate = DateTime.MaxValue;
ServiceIdentityKey key = new ServiceIdentityKey()
{
EndDate = endDate.ToUniversalTime(),
StartDate = startDate.ToUniversalTime(),
Type = "Password",
Usage = "Password",
Value = Encoding.UTF8.GetBytes(password),
DisplayName = String.Format(CultureInfo.InvariantCulture, "{0} key for {1}", "Password", name)
};
svc.AddToServiceIdentities(sid);
svc.AddRelatedObject(
sid,
"ServiceIdentityKeys",
key);
svc.SaveChanges(SaveChangesOptions.Batch);
This example is from MSDN - How to: Use ACS Management Service to Configure Service Identies.