public AzureResourceGroupClient(
     HttpClient client, IHttp http, IJson json, IOptions <AzureOptions> azureOptions,
     ILogger <AzureResourceGroupClient> log)
     : base(client, http, json, log)
 {
     _azureOptions = azureOptions.Value;
 }
        public TemplatesRepository(AzureOptions options)
        {
            this.options = options ?? throw new ArgumentNullException(nameof(options));
            var storageAccount = CloudStorageAccount.Parse(options.ConnectionString);

            tableClient = storageAccount.CreateCloudTableClient();
            blobClient  = storageAccount.CreateCloudBlobClient();
        }
Пример #3
0
 public IoTCentralService(AzureOptions azureOptions)
 {
     _azureOptions = azureOptions;
     ApiDeviceUrl  = string.Format("https://{0}/api/preview/devices/{1}/modules/CameraCapture/properties",
                                   _azureOptions.IoTCentral.IoTCentralDomain,
                                   _azureOptions.IoTCentral.DeviceId);
     Client = InitClient();
 }
 public static void AddFluffySpoonLetsEncryptAzureAppServiceSslBindingCertificatePersistence(
     this IServiceCollection services,
     AzureOptions azureOptions)
 {
     services.AddFluffySpoonLetsEncryptCertificatePersistence(
         (provider) => new AzureAppServiceSslBindingCertificatePersistenceStrategy(
             azureOptions,
             provider.GetRequiredService <LetsEncryptOptions>(),
             provider.GetRequiredService <ILogger <IAzureAppServiceSslBindingCertificatePersistenceStrategy> >()));
 }
Пример #5
0
 public AuthorizationService(
     IAuthorizationTokenRepository authorizationTokenRepository,
     ILoginRequestService loginRequestService,
     IMapper mapper,
     IOptions <SpotifyOptions> spotifyOptions,
     IOptions <AzureOptions> azureOptions)
 {
     _authorizationTokenRepository = authorizationTokenRepository;
     _loginRequestService          = loginRequestService;
     _mapper         = mapper;
     _spotifyOptions = spotifyOptions.Value;
     _azureOptions   = azureOptions.Value;
 }
Пример #6
0
 public AzureRestClient(
     IOptions <AzureOptions> azureOptions,
     IOptions <ServicePrincipleOptions> servicePrincipleOptions,
     IOptions <VirtualMachineOptions> virtualMachineOptions)
 {
     _azureOptions            = azureOptions?.Value;
     _servicePrincipleOptions = servicePrincipleOptions?.Value;
     _virtualMachineOptions   = virtualMachineOptions?.Value;
     _bearerTokenUri          = new Uri($"https://login.microsoftonline.com/{_azureOptions.TenantId}/oauth2/token");
     _dealocateVmEndpoint     = new Uri(_azureOptions.ResourceUri, $"/subscriptions/{_azureOptions.SubscriptionId}/resourceGroups/{_virtualMachineOptions.ResourceGroupName}/providers/Microsoft.Compute/virtualMachines/{_virtualMachineOptions.Name}/deallocate?api-version=2019-03-01");
     _startVmEndpoint         = new Uri(_azureOptions.ResourceUri, $"/subscriptions/{_azureOptions.SubscriptionId}/resourceGroups/{_virtualMachineOptions.ResourceGroupName}/providers/Microsoft.Compute/virtualMachines/{_virtualMachineOptions.Name}/start?api-version=2019-03-01");
     _vmStateEndpoint         = new Uri(_azureOptions.ResourceUri, $"/subscriptions/{_azureOptions.SubscriptionId}/resourceGroups/{_virtualMachineOptions.ResourceGroupName}/providers/Microsoft.Compute/virtualMachines/{_virtualMachineOptions.Name}/instanceView?api-version=2019-03-01");
 }
Пример #7
0
        private static void AddCloudLogging(this ILoggingBuilder builder, IConfiguration config)
        {
            var cloudConfig = config.GetSection("Cloud");

            switch (cloudConfig["Provider"])
            {
            case nameof(Azure):
            {
                var cloudOptions = new AzureOptions();
                cloudConfig.FastBind(cloudOptions);
                builder.ConfigureCloudLogging(cloudOptions);
                break;
            }
            }
        }
Пример #8
0
 public ConfigController(IInventoryService inventoryService, AzureOptions options)
 {
     _options          = options;
     _inventoryService = inventoryService;
 }
 public static IServiceCollection AddAzureSmsNotification(this IServiceCollection services, AzureOptions options)
 {
     services.AddSingleton <ISmsNotification>(new AzureSmsNotification(options));
     return(services);
 }
Пример #10
0
 public LocationController(IAzureMapsApiService azureMapsApiService, AzureOptions options)
 {
     _azureMapsApiService = azureMapsApiService;
     _options             = options;
 }
 public CreatePetsitterDTOToUserConverter(IGraphService graphService)
 {
     _azureOptions = graphService.AzureOptions;
 }
 public AzureStorageProviderClient(
     HttpClient client, IHttp http, IJson json, IOptions <AzureOptions> azureOptions, ILogger <AzureStorageProviderClient> log)
     : base(client, http, json, log)
 {
     _azureOptions = azureOptions.Value;
 }
Пример #13
0
 public SqlService(AzureOptions azureOptions)
 {
     _azureOptions = azureOptions;
 }
 public CloudStorageAccountFactory(IOptions<ConfigurationOptions> optionsAccessor)
 {
     this.azureOptions = optionsAccessor.Value.Azure;
 }
Пример #15
0
Файл: Add.cs Проект: qiqi545/HQ
        public static IServiceCollection AddHq(this IServiceCollection services, IWebHostEnvironment env,
                                               IConfiguration config, ISafeLogger logger)
        {
            var subject = Assembly.GetCallingAssembly();

            if (!(config is IConfigurationRoot configRoot))
            {
                throw new ArgumentException("HQ requires access to the root configuration.", nameof(config));
            }

            services.TryAddSingleton(configRoot);
            services.TryAddSingleton(services);

            var hq = configRoot.GetSection("HQ");

            //
            // Core Services:
            services.AddTypeResolver();
            services.AddLocalTimestamps();
            services.AddSafeLogging();
            services.AddValidOptions();
            services.AddTraceContext();

            //
            // Platform Services:
            services.AddSecurityPolicies(hq.GetSection("Security"), hq.GetSection("SuperUser"), logger);
            services.AddVersioning(hq.GetSection("Versioning"));
            services.AddMultiTenancy <IdentityTenant, IdentityApplication>(hq.GetSection("MultiTenancy"))
            .AddIdentityTenantContextStore <IdentityTenant>()
            .AddIdentityApplicationContextStore <IdentityApplication>();

            //
            // Platform APIs:
            services
            .AddOperationsApi(hq.GetSection("Ops"))
            .AddPlatformApi(hq.GetSection("Api"))
            .AddBackgroundTasksApi(hq.GetSection("BackgroundTasks"))
            .AddConfigurationApi(configRoot, hq.GetSection("Configuration"))
            .AddIdentityApi(hq.GetSection("IdentityApi"))
            .AddSchemaApi(hq.GetSection("Schema"))
            .AddMetaApi(hq.GetSection("Meta"));

            var tasksBuilder    = services.AddBackgroundTasks(hq.GetSection("BackgroundTasks"));
            var identityBuilder = services.AddIdentityExtended(hq.GetSection("Identity"));
            var runtimeBuilder  = services.AddRuntimeApi(hq.GetSection("Runtime"));
            var schemaBuilder   = services.AddSchemaDiscovery(hq.GetSection("Schema"));

            //
            // Cloud:
            var cloud = configRoot.GetSection("Cloud");

            switch (cloud["Provider"])
            {
            case nameof(Azure):
            {
                var options = new AzureOptions();
                cloud.FastBind(options);
                services.AddCloudServices(logger, options);
                break;
            }
            }

            //
            // Backend Services:
            var backend  = configRoot.GetSection("Backend");
            var dbConfig = backend.GetSection("DbOptions");

            if (dbConfig?.Value == null)
            {
                dbConfig = null;
            }

            var backendType = backend["Type"];

            if (string.IsNullOrWhiteSpace(backendType))
            {
                logger.Warn(() => "No backend type found!");
            }
            else
            {
                logger.Info(() => "Installing {BackendType} back-end services.", backendType);
            }

            switch (backendType)
            {
            case nameof(DocumentDb):
                tasksBuilder.AddDocumentDbBackgroundTaskStore(backend.GetConnectionString("Tasks"));
                identityBuilder.AddDocumentDbIdentityStore <IdentityUserExtended, IdentityRoleExtended, IdentityTenant, IdentityApplication>(backend.GetConnectionString("Identity"));
                runtimeBuilder.AddDocumentDbRuntimeStores(backend.GetConnectionString("Runtime"), ConnectionScope.ByRequest, dbConfig);
                schemaBuilder.AddDocumentDbSchemaStores(backend.GetConnectionString("Schema"));
                break;

            case nameof(SqlServer):
                tasksBuilder.AddSqlServerBackgroundTasksStore(backend.GetConnectionString("Tasks"), r => r.GetRequiredService <IServerTimestampService>().GetCurrentTime());
                identityBuilder.AddSqlServerIdentityStore <IdentityUserExtended, IdentityRoleExtended, IdentityTenant, IdentityApplication>(backend.GetConnectionString("Identity"), ConnectionScope.ByRequest, dbConfig);
                runtimeBuilder.AddSqlServerRuntime(backend.GetConnectionString("Runtime"), ConnectionScope.ByRequest, dbConfig);
                schemaBuilder.AddSqlServerSchemaStores();
                break;

            case nameof(Sqlite):
                tasksBuilder.AddSqliteBackgroundTasksStore(backend.GetConnectionString("Tasks"));
                identityBuilder.AddSqliteIdentityStore <IdentityUserExtended, IdentityRoleExtended, IdentityTenant, IdentityApplication>(backend.GetConnectionString("Identity"), ConnectionScope.ByRequest, dbConfig);
                runtimeBuilder.AddSqliteRuntime(backend.GetConnectionString("Runtime"), ConnectionScope.ByRequest, dbConfig);
                schemaBuilder.AddSqliteSchemaStores();
                break;

            default:
                throw new ArgumentOutOfRangeException(backendType, typeof(string), null);
            }

            //
            // Runtime Services:
            {
                var runtimeOptions = new RuntimeOptions();
                hq.GetSection("Runtime").FastBind(runtimeOptions);

                if (runtimeOptions.EnableRest)
                {
                    services.AddRestRuntime();
                    logger.Info(() => "REST is enabled.");
                }

                if (runtimeOptions.EnableGraphQl)
                {
                    services.AddGraphQlRuntime();
                    logger.Info(() => "GraphQL is enabled.");
                }
            }

            //
            // Notification Services:
            services.AddEmailNotifications(hq.GetSection("Email"));

            //
            // Media Services:

            //
            // Custom Objects:
            services.ScanForGeneratedObjects(backendType, hq.GetSection("Security"), logger, "/api", subject);

            return(services);
        }
Пример #16
0
 public MapsController(IAzureMapsApiService azureMapsApiService, AzureOptions options)
 {
     _azureMapsApiService = azureMapsApiService;
 }
Пример #17
0
 public AzureMapsApiService(AzureOptions azureOptions)
 {
     _azureOptions = azureOptions;
 }