Integrating secrets.json into function app development

This commit is contained in:
John Rampono 2020-12-17 12:36:50 +08:00
Родитель 3dc5b4f73d
Коммит 80d5de088f
8 изменённых файлов: 140 добавлений и 131 удалений

9
CODE_OF_CONDUCT.md Normal file
Просмотреть файл

@ -0,0 +1,9 @@
# Microsoft Open Source Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
Resources:
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns

41
SECURITY.md Normal file
Просмотреть файл

@ -0,0 +1,41 @@
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.5 BLOCK -->
## Security
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below.
## Reporting Security Issues
**Please do not report security vulnerabilities through public GitHub issues.**
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue
This information will help us triage your report more quickly.
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.
## Preferred Languages
We prefer all communications to be in English.
## Policy
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
<!-- END MICROSOFT SECURITY.MD BLOCK -->

25
SUPPORT.md Normal file
Просмотреть файл

@ -0,0 +1,25 @@
# TODO: The maintainer of this repo has not yet edited this file
**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project?
- **No CSS support:** Fill out this template with information about how to file issues and get help.
- **Yes CSS support:** Fill out an intake form at [aka.ms/spot](https://aka.ms/spot). CSS will work with/help you to determine next steps. More details also available at [aka.ms/onboardsupport](https://aka.ms/onboardsupport).
- **Not sure?** Fill out a SPOT intake as though the answer were "Yes". CSS will help you decide.
*Then remove this first heading from this SUPPORT.MD file before publishing your repo.*
# Support
## How to file issues and get help
This project uses GitHub Issues to track bugs and feature requests. Please search the existing
issues before filing new issues to avoid duplicates. For new issues, file your bug or
feature request as a new Issue.
For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE
FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER
CHANNEL. WHERE WILL YOU HELP PEOPLE?**.
## Microsoft Support Policy
Support for this **PROJECT or PRODUCT** is limited to the resources listed above.

Просмотреть файл

@ -24,6 +24,7 @@
<TargetDatabaseSet>True</TargetDatabaseSet>
<DefaultCollation>SQL_Latin1_General_CP1_CI_AS</DefaultCollation>
<DefaultFilegroup>PRIMARY</DefaultFilegroup>
<GenerateCreateScript>True</GenerateCreateScript>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>

Просмотреть файл

@ -44,6 +44,18 @@ INSERT INTO [dbo].[ScheduleMaster] ([ScheduleCronExpression],[ScheduleDesciption
VALUES ('0 0 1 */3 * *','At 00:00 on day-of-month 1 in every 3rd month',1)
GO
/*
Subject Area
*/
SET IDENTITY_INSERT [dbo].[SubjectArea] ON
INSERT INTO [dbo].[SubjectArea] ([SubjectAreaId], [SubjectAreaName], [ActiveYN], [SubjectAreaFormId], [DefaultTargetSchema], [UpdatedBy]) VALUES (1, N'Default - Admin', 1, NULL, N'**ALL**', N'jorampon@microsoft.com')
INSERT INTO [dbo].[SubjectArea] ([SubjectAreaId], [SubjectAreaName], [ActiveYN], [SubjectAreaFormId], [DefaultTargetSchema], [UpdatedBy]) VALUES (2, N'Secured - Test SubjectArea', 1, NULL, N'TestSubjectArea', N'jorampon@microsoft.com')
SET IDENTITY_INSERT [dbo].[SubjectArea] OFF
/*
TASKGROUP
*/
@ -51,33 +63,33 @@ TASKGROUP
TRUNCATE TABLE [dbo].[TaskGroup]
Go
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Load Excel',0,10,null,1)
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[SubjectAreaId], [TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Load Excel',1, 0,10,null,1)
GO
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Load AwSample',0,10,null,1)
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[SubjectAreaId], [TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Load AwSample', 1,0,10,null,1)
GO
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Load OnPrem Adventureworks',0,10,null,1)
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[SubjectAreaId], [TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Load OnPrem Adventureworks', 1,0,10,null,1)
GO
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Persist AwSample in Azure SQL',0,10,null,1)
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[SubjectAreaId], [TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Persist AwSample in Azure SQL', 1,0,10,null,1)
GO
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Generate Task Masters',0,10,null,1)
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[SubjectAreaId], [TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Generate Task Masters',1, 0,10,null,1)
GO
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Persist Adventureworks in Azure SQL',0,10,null,1)
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[SubjectAreaId], [TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Persist Adventureworks in Azure SQL',1, 0,10,null,1)
GO
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Move between Storage',0,10,null,1)
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[SubjectAreaId], [TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Move between Storage',1, 0,10,null,1)
GO
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Build Dimensions',0,10,null,1)
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[SubjectAreaId], [TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Build Dimensions',1, 0,10,null,1)
GO
/*SasURI Sample Group*/
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Generate SAS URI',0,10,null,1)
INSERT INTO [dbo].[TaskGroup] ([TaskGroupName],[SubjectAreaId], [TaskGroupPriority],[TaskGroupConcurrency],[TaskGroupJSON],[ActiveYN])
Values ('Generate SAS URI',1, 0,10,null,1)
GO
/*
@ -118,106 +130,3 @@ VALUES ('','','','')
INSERT INTO [dbo].[DataFactory] ([Name],[ResourceGroup],[SubscriptionUid],[DefaultKeyVaultURL])
VALUES ('adsgofastdatakakeacceladf','AdsGoFastDataLakeAccel','xxxxxxxxxxxxxxxxxxx','https://xxxxxxxxxxxxxxxxxxxx.vault.azure.net/')
GO
/*
--Delete Unsupported datatype
DELETE from dbo.TaskMaster
where TaskMasterId in (
SELECT TaskMasterId FROM TaskInstance WHERE TaskInstanceId IN (SELECT distinct TaskInstanceId FROM ActivityAudit Where status = 'Failed' and Comment like '%Please add conversion logic to %')
)
DELETE TaskInstance WHERE TaskInstanceId IN (SELECT distinct TaskInstanceId FROM ActivityAudit Where status = 'Failed' and Comment like '%Please add conversion logic to %')
DELETE FROM TaskInstance Where TaskMasterId in (SELECT TaskMasterId FROM TaskMaster Where TaskMasterName like '%Person%Address%')
DELETE FROM TaskMaster Where TaskMasterName like '%Person%Address%'
DELETE FROM TaskInstance Where TaskMasterId in (SELECT TaskMasterId FROM TaskMaster Where TaskMasterName like '%Production%ProductDocument%')
DELETE FROM TaskMaster Where TaskMasterName like '%Production%ProductDocument%'
DELETE FROM TaskInstance Where TaskMasterId in (SELECT TaskMasterId FROM TaskMaster Where TaskMasterName like '%HumanResources%Shift%')
DELETE FROM TaskMaster Where TaskMasterName like '%HumanResources%Shift%'
DELETE FROM TaskInstance Where TaskMasterId in (SELECT TaskMasterId FROM TaskMaster Where TaskMasterName like '%HumanResources%JobCandidate%')
DELETE FROM TaskMaster Where TaskMasterName like '%HumanResources%JobCandidate%'
DELETE FROM TaskInstance Where TaskMasterId in (SELECT TaskMasterId FROM TaskMaster Where TaskMasterName like '%HumanResources%Employee%')
DELETE FROM TaskMaster Where TaskMasterName like '%HumanResources%Employee%'
DELETE FROM TaskInstance Where TaskMasterId in (SELECT TaskMasterId FROM TaskMaster Where TaskMasterName like '%Production%Document%')
DELETE FROM TaskMaster Where TaskMasterName like '%Production%Document%'
--Set Table PrimaryKey
-- WaterMark with Chunk
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'{@TablePrimaryKey}','CustomerID') Where TaskMasterName like 'AwSample SalesLT.Customer Extract to Data Lake'
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'{@TablePrimaryKey}','ProductModelID') Where TaskMasterName like 'AwSample SalesLT.ProductModel Extract to Data Lake'
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'{@TablePrimaryKey}','ProductDescriptionID') Where TaskMasterName like 'AwSample SalesLT.ProductDescription Extract to Data Lake'
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'{@TablePrimaryKey}','ProductID') Where TaskMasterName like 'AwSample SalesLT.Product Extract to Data Lake'
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'{@TablePrimaryKey}','ProductCategoryID') Where TaskMasterName like 'AwSample SalesLT.ProductCategory Extract to Data Lake'
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'{@TablePrimaryKey}','SystemInformationID') Where TaskMasterName like 'AwSample dbo.BuildVersion Extract to Data Lake'
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'{@TablePrimaryKey}','ErrorLogID') Where TaskMasterName like 'AwSample dbo.ErrorLog Extract to Data Lake'
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'{@TablePrimaryKey}','AddressID') Where TaskMasterName like 'AwSample SalesLT.Address Extract to Data Lake'
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'{@TablePrimaryKey}','SalesOrderDetailID') Where TaskMasterName like 'AwSample SalesLT.SalesOrderDetail Extract to Data Lake'
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'{@TablePrimaryKey}','SalesOrderID') Where TaskMasterName like 'AwSample SalesLT.SalesOrderHeader Extract to Data Lake'
--Reduce Chunk to 100 for testing
--UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'"5000"','"100"') Where TaskMasterName like 'AwSample%Extract to Data Lake'
--Full Load with Chunk
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'"Watermark"','"Full"') Where TaskMasterName like 'AwSample SalesLT.ProductCategory Extract to Data Lake'
--FULL Load with no chunk
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'"Watermark"','"Full"') Where TaskMasterName like 'AwSample SalesLT.ProductModelProductDescription Extract to Data Lake'
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'"5000"','""') Where TaskMasterName like 'AwSample SalesLT.ProductModelProductDescription Extract to Data Lake'
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'"Watermark"','"Full"') Where TaskMasterName like 'AwSample SalesLT.CustomerAddress Extract to Data Lake'
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'"500"','""') Where TaskMasterName like 'AwSample SalesLT.CustomerAddress Extract to Data Lake'
-- WaterMark with Chunk
UPDATE [dbo].[TaskMaster] SET TaskMasterJSON = Replace(TaskMasterJSON,'"5000"','""') Where TaskMasterName like 'AwSample SalesLT.SalesOrderHeader Extract to Data Lake'
UPDATE [dbo].[TaskMaster] SET ActiveYN = 1 Where TaskMasterName like 'AwSample%Extract to Data Lake'
-- Create WaterMark
TRUNCATE TABLE [dbo].[TaskMasterWaterMark]
GO
INSERT INTO [dbo].[TaskMasterWaterMark]
([TaskMasterId],[TaskMasterWaterMarkColumn],[TaskMasterWaterMarkColumnType],[TaskMasterWaterMark_DateTime],[TaskMasterWaterMark_BigInt],[TaskWaterMarkJSON],[ActiveYN],[UpdatedOn])
SELECT TaskMasterId, CASE WHEN TaskMasterName like 'AwSample%ErrorLog%Extract to Data Lake' THEN 'ErrorTime' ELSE 'ModifiedDate' END,'DateTime',null,null,null,1,GETDATE() FROM [dbo].[TaskMaster] Where TaskMasterName like 'AwSample%Extract to Data Lake'
GO
INSERT INTO [dbo].[TaskMasterWaterMark]
([TaskMasterId],[TaskMasterWaterMarkColumn],[TaskMasterWaterMarkColumnType],[TaskMasterWaterMark_DateTime],[TaskMasterWaterMark_BigInt],[TaskWaterMarkJSON],[ActiveYN],[UpdatedOn])
SELECT TaskMasterId, 'ModifiedDate','DateTime',null,null,null,1,GETDATE() FROM [dbo].[TaskMaster] Where TaskMasterName like 'AdventureWorks2017%' and TaskMasterJSON like '%Watermark%'
GO
-- OnPrem Full-Chunk
UPDATE TaskMaster Set TaskMasterJSON = REPLACE(TaskMasterJSON,'"IncrementalType": "Full"','"IncrementalType": "Full", "ChunkField": "CustomerID", "ChunkSize": "5000"') WHERE TaskMasterName like 'AdventureWorks2017%Sales%Customer%'
-- OnPrem Watermark
UPDATE TaskMaster Set TaskMasterJSON = REPLACE(TaskMasterJSON,'"IncrementalType": "Full"','"IncrementalType": "Watermark", "ChunkField": "SalesOrderID", "ChunkSize": ""') WHERE TaskMasterName like 'AdventureWorks2017%SalesOrderDetail%'
-- OnPrem Watermark-Chunk
UPDATE TaskMaster Set TaskMasterJSON = REPLACE(TaskMasterJSON,'"IncrementalType": "Full"','"IncrementalType": "Watermark", "ChunkField": "SalesOrderID", "ChunkSize": "5000"') WHERE TaskMasterName like 'AdventureWorks2017%SalesOrderHeader %'
INSERT INTO dbo.ADFPrice VALUES ('Orchestration','Runs',1.373/1000,'AUD','AzureIR','Activity, trigger and debug runs',getdate())
INSERT INTO dbo.ADFPrice VALUES ('Orchestration','Runs',1.373/1000,'AUD','Azure managed VNET integration runtime','Activity, trigger and debug runs',getdate())
INSERT INTO dbo.ADFPrice VALUES ('Orchestration','Runs',2.060/1000,'AUD','SelfhostedIR','Activity, trigger and debug runs',getdate())
INSERT INTO dbo.ADFPrice VALUES ('Execution-Data movement activities','DIU-hour',0.344,'AUD','AzureIR','Cost to execute an Azure Data Factory activity on the Azure integration runtime',getdate())
INSERT INTO dbo.ADFPrice VALUES ('Execution-Pipeline activities','Hour',0.007,'AUD','AzureIR','Cost to execute an Azure Data Factory activity on the Azure integration runtime',getdate())
INSERT INTO dbo.ADFPrice VALUES ('Execution-External pipeline activities','Hour',0.000344,'AUD','AzureIR','Cost to execute an Azure Data Factory activity on the Azure integration runtime',getdate())
INSERT INTO dbo.ADFPrice VALUES ('Execution-Data movement activities','DIU-hour',0.344,'AUD','Azure managed VNET integration runtime','Cost to execute an Azure Data Factory activity on the Azure managed VNET integration runtime',getdate())
INSERT INTO dbo.ADFPrice VALUES ('Execution-Pipeline activities','Hour',1.373,'AUD','Azure managed VNET integration runtime','Cost to execute an Azure Data Factory activity on the Azure managed VNET integration runtime',getdate())
INSERT INTO dbo.ADFPrice VALUES ('Execution-External pipeline activities','Hour',1.373,'AUD','Azure managed VNET integration runtime','Cost to execute an Azure Data Factory activity on the Azure managed VNET integration runtime',getdate())
INSERT INTO dbo.ADFPrice VALUES ('Execution-Data movement activities','DIU-hour',0.138,'AUD','SelfhostedIR','Cost to execute an Azure Data Factory activity on a self-hosted integration runtime',getdate())
INSERT INTO dbo.ADFPrice VALUES ('Execution-Pipeline activities','Hour',0.003,'AUD','SelfhostedIR','Cost to execute an Azure Data Factory activity on a self-hosted integration runtime',getdate())
INSERT INTO dbo.ADFPrice VALUES ('Execution-External pipeline activities','Hour',0.000138,'AUD','SelfhostedIR','Cost to execute an Azure Data Factory activity on a self-hosted integration runtime',getdate())
*/

Просмотреть файл

@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<UserSecretsId>3956e7aa-4d13-430a-bb5f-a5f8f5a450ee</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<None Remove="SqlTemplates\InsertActivityAudit.sql" />
@ -28,6 +29,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.5" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.7" />
<PackageReference Include="Microsoft.Azure.Management.Compute.Fluent" Version="1.34.0" />
@ -38,6 +40,7 @@
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="5.2.7" />
<PackageReference Include="NJsonSchema" Version="10.1.26" />
<PackageReference Include="SendGrid" Version="9.21.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.1" />

Просмотреть файл

@ -10,11 +10,12 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Configuration;
using System.Linq;
using System.Net.Http;
using System.Reflection.Metadata;
using System.Security.Cryptography;
using System.Configuration;
namespace AdsGoFast
{
@ -580,15 +581,23 @@ namespace AdsGoFast
private static object GetConfig(string ConfigName)
{
object Ret;
try
{
Ret = System.Environment.GetEnvironmentVariable(ConfigName, EnvironmentVariableTarget.Process);
}
catch (Exception e)
{
//Logging.LogErrors(new Exception ("Could not find global config " + ConfigName));
throw (e);
}
try
{
//Todo refactor config helper to use dependency injection
var config = new ConfigurationBuilder()
.SetBasePath(Environment.CurrentDirectory)
.AddEnvironmentVariables()
.AddUserSecrets(System.Reflection.Assembly.GetExecutingAssembly(), true)
.Build();
Ret = config[ConfigName];
}
catch (Exception e)
{
//Logging.LogErrors(new Exception ("Could not find global config " + ConfigName));
throw (e);
}
return Ret;
}

Просмотреть файл

@ -1,5 +1,8 @@
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Reflection;
[assembly: FunctionsStartup(typeof(AdsGoFast.Startup))]
namespace AdsGoFast
@ -8,6 +11,15 @@ namespace AdsGoFast
{
public override void Configure(IFunctionsHostBuilder builder)
{
var config = new ConfigurationBuilder()
.SetBasePath(Environment.CurrentDirectory)
.AddUserSecrets(Assembly.GetExecutingAssembly(), true)
.AddEnvironmentVariables()
.Build();
builder.Services.AddSingleton<IConfiguration>(config);
builder.Services.AddScoped<Logging>((s) =>
{
return new Logging();