This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<system.serviceModel> | |
<behaviors> | |
<serviceBehaviors> | |
<behavior> | |
<!-- snip --> | |
<bearerTokenRequired/> | |
</behavior> | |
</serviceBehaviors> | |
</behaviors> | |
<extensions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class WcfErrorResponseData | |
{ | |
public WcfErrorResponseData(HttpStatusCode status) : this(status, string.Empty, new KeyValuePair<string, string>[0]){ } | |
public WcfErrorResponseData(HttpStatusCode status, string body) : this(status, body, new KeyValuePair<string, string>[0]) { } | |
public WcfErrorResponseData(HttpStatusCode status, string body, params KeyValuePair<string, string>[] headers) | |
{ | |
StatusCode = status; | |
Body = body; | |
Headers = headers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class AzureAdToken | |
{ | |
public static string Get() | |
{ | |
const string clientSecret = "CLIENT_SECRET"; | |
const string clientId = "CLIENT_ID"; | |
var ctx = new AuthenticationContext("https://login.windows.net/TENANT_NAME_OR_ID"); | |
var token = ctx.AcquireToken("TARGET_RESOURCE", new ClientCredential(clientId, clientSecret)); | |
return token.AccessToken; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class EndpointExtension | |
{ | |
public static void AddAuthorizationEndpointBehavior(this ServiceEndpoint endpoint) | |
{ | |
endpoint.EndpointBehaviors.Add(new AuthorizationHeaderEndpointBehavior()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = new Auth.AuthServiceClient(); | |
a.Endpoint.AddAuthorizationEndpointBehavior(); | |
var me = a.WhoAmI(); | |
Console.WriteLine(me); | |
Console.ReadLine(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"oauth2Permissions": [ | |
{ | |
"adminConsentDescription": "Allow the application access to the service", | |
"adminConsentDisplayName": "Have full access to the service", | |
"id": "b69ee3c9-c40d-4f2a-ac80-961cd1534e40", | |
"isEnabled": true, | |
"origin": "Application", | |
"type": "User", | |
"userConsentDescription": "Allow the application full access to the service on your behalf", | |
"userConsentDisplayName": "Have full access to the service", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async static void AddDocuments<T>(IList<T> things) where T : class, new() | |
{ | |
var indexClient = new SearchIndexClient(ConfigurationManager.AppSettings["SearchServiceName"], things.First().GetType().Name.ToLower(), new SearchCredentials(ConfigurationManager.AppSettings["SearchServiceApiKey"])); | |
try | |
{ | |
Trace.WriteLine($"Adding {things.Count()} documents to the index..."); | |
var thingsToIndex = things.Where(x => x.GetType().GetProperties().Any(prop => prop.GetCustomAttribute<IndexMetadataAttribute>() != null)); | |
var newThings = thingsToIndex.Select(x => | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SomeEntity : TableEntity | |
{ | |
[IndexMetadata("Id", IsKey = true, IsRetrievable = true, IsSearchable = true, IsSortable = true)] | |
public string Id | |
{ | |
get { return RowKey; } | |
set { RowKey = value; } | |
} | |
[IndexMetadata("Title", IsKey = false, IsRetrievable = true, IsSearchable = true, IsSortable = true)] | |
public string Title { get; set; } |
OlderNewer