コード例 #1
0
 public AzureResourceGroupClient(
     HttpClient client, IHttp http, IJson json, IOptions <AzureOptions> azureOptions,
     ILogger <AzureResourceGroupClient> log)
     : base(client, http, json, log)
 {
     _azureOptions = azureOptions.Value;
 }
コード例 #2
0
        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();
 }
コード例 #4
0
 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
ファイル: Configure.cs プロジェクト: qiqi545/HQ
        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
ファイル: ConfigController.cs プロジェクト: rploeg/IoTDemos
 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;
 }
コード例 #11
0
 public CreatePetsitterDTOToUserConverter(IGraphService graphService)
 {
     _azureOptions = graphService.AzureOptions;
 }
コード例 #12
0
 public AzureStorageProviderClient(
     HttpClient client, IHttp http, IJson json, IOptions <AzureOptions> azureOptions, ILogger <AzureStorageProviderClient> log)
     : base(client, http, json, log)
 {
     _azureOptions = azureOptions.Value;
 }
コード例 #13
0
ファイル: SqlService.cs プロジェクト: rploeg/IoTDemos
 public SqlService(AzureOptions azureOptions)
 {
     _azureOptions = azureOptions;
 }
コード例 #14
0
 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
ファイル: MapsController.cs プロジェクト: rploeg/IoTDemos
 public MapsController(IAzureMapsApiService azureMapsApiService, AzureOptions options)
 {
     _azureMapsApiService = azureMapsApiService;
 }
コード例 #17
0
 public AzureMapsApiService(AzureOptions azureOptions)
 {
     _azureOptions = azureOptions;
 }