зеркало из
1
0
Форкнуть 0
This commit is contained in:
praveensri 2021-03-16 01:39:56 -07:00
Родитель 80aed8b516
Коммит 311c4a57fc
11 изменённых файлов: 113 добавлений и 162 удалений

21
LICENSE.txt Normal file
Просмотреть файл

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Microsoft Azure
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

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

@ -1,7 +1,15 @@
# Starter pipeline
- task: UseDotNet@2
displayName: 'Install .NET Core SDK'
inputs:
version: '3.0.x'
packageType: runtime
- task: DotNetCoreCLI@2
inputs:
command: 'build'
- task: VSTest@2
inputs:
testSelector: 'testAssemblies'
@ -16,7 +24,7 @@
# https://aka.ms/yaml
trigger:
- main
- CosmosDB
pool:
vmImage: ubuntu-latest

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

@ -1,62 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Autofac" version="3.5.2" targetFramework="net40" />
<package id="Autofac.WebApi2" version="3.4.0" targetFramework="net45" />
<package id="Azure.BizTalk.FlatFile" version="1.0.411.842" targetFramework="net40" />
<package id="AzureUX.ARM.Externals.Azure" version="2.9.5.4" />
<package id="AzureUX.ARM.Externals.MonAuditing" version="1.0.0" />
<package id="AzureUX.ARM.Externals.IIS" version="1.0.0" />
<package id="AzureUX.Externals.Deployment.Binaries" version="1.9.5.4" />
<package id="AzureUX.Externals.Deployment" version="1.3.71" />
<package id="GenevaMonitoringAgentLibs" version="44.5.1" />
<package id="BCDT.amd64" version="2.0.4-CBT2" developmentDependency="true" />
<package id="Bond.CSharp" version="3.0.7" />
<package id="Bond.Runtime.CSharp" version="3.0.7" />
<package id="GenevaMonitoringAgent" version="44.5.1" />
<package id="Internal.WindowsAzure.ResourceStack.Tests.Common" version="6.0.0.1219" targetFramework="net461" />
<package id="Internal.WindowsAzure.ResourceStack.Tests.Common.Core" version="6.0.0.1219" targetFramework="net461" />
<package id="Localization" version="3.2.0" />
<package id="log4net" version="2.0.3" />
<package id="LogicApps-TestFiles" version="1.0.0" />
<package id="Microsoft.AspNet.OData" version="6.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.SelfHost" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.Azure.Connectors.Common" version="1.0.1221.1619" targetFramework="net45" />
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net40" />
<package id="Microsoft.Azure.WebJobs" version="2.2.0" targetFramework="net45" />
<package id="Microsoft.Cloud.InstrumentationFramework" version="3.0.6.101" targetFramework="net40" />
<package id="Microsoft.Data.Edm" version="5.8.4" targetFramework="net40" />
<package id="Microsoft.Data.OData" version="5.8.4" targetFramework="net40" />
<package id="Microsoft.Data.Services.Client" version="5.8.4" targetFramework="net40" />
<package id="Microsoft.Identity.ServerAuthorization" version="2.5.2" targetFramework="net462" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net45" />
<package id="Microsoft.OData.Core" version="7.0.0" />
<package id="Microsoft.OData.Edm" version="7.0.0" />
<package id="Microsoft.Spatial" version="7.0.0" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.1.0" targetFramework="net40" />
<package id="Microsoft.WindowsAzure.ResourceStack" version="6.0.0.1219" targetFramework="net461" />
<package id="Microsoft.WindowsAzure.ResourceStack.Compression" version="6.0.0.1219" targetFramework="net461" />
<package id="MimeKit" version="2.1.3" targetFramework="net45" />
<package id="MsBuild.Corext" version="15.7.177.10" />
<package id="MsTest.Corext" version="10.0.0" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net45" />
<package id="Newtonsoft.Json.Schema" version="3.0.10" targetFramework="net45" />
<package id="PortalFx.IisBrotli" version="10.0.0.39" />
<package id="Pipelines.Sockets.Unofficial" version="2.0.22" targetFramework="net461" />
<package id="Redis-64" version="3.0.501" />
<package id="ResourceStack.Storage.Client" version="5.0.6.5576" targetFramework="net45" />
<package id="StackExchange.Redis" version="2.0.601" targetFramework="net472" />
<package id="System.Buffers" version="4.4.0" />
<package id="System.Diagnostics.PerformanceCounter" version="4.5.0" targetFramework="net461" />
<package id="System.IdentityModel.Tokens.Jwt" version="4.0.2.206221351" targetFramework="net45" />
<package id="System.IO.Pipelines" version="4.5.1" />
<package id="System.Memory" version="4.5.1" />
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net46" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" />
<package id="System.Spatial" version="5.8.4" targetFramework="net40" />
<package id="System.Threading.Channels" version="4.5.0" />
<package id="System.Threading.Tasks.Extensions" version="4.5.1" />
<package id="WindowsAzure.Storage" version="9.3.3" targetFramework="net45" />
</packages>

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

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

@ -4,22 +4,20 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>test.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>..\..\sign.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.3" />
<PackageReference Include="Microsoft.Azure.Workflows.WebJobs.Extension" Version="1.0.1.2-preview" />
<PackageReference Include="Microsoft.Azure.Workflows.WebJobs.Extension" Version="*-*" />
</ItemGroup>
<ItemGroup>
<None Update="icon.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="tools\deploy.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

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

@ -1,25 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30503.244
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB", "Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB.csproj", "{B58DD1C3-0141-41B6-B086-4F4745B04DFB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B58DD1C3-0141-41B6-B086-4F4745B04DFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B58DD1C3-0141-41B6-B086-4F4745B04DFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B58DD1C3-0141-41B6-B086-4F4745B04DFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B58DD1C3-0141-41B6-B086-4F4745B04DFB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BFBA28BE-9B3B-4E33-A597-C95445B11C87}
EndGlobalSection
EndGlobal

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

@ -1,24 +1,23 @@
using Microsoft.Azure.WebJobs.Description;
using Microsoft.Azure.WebJobs.Host.Config;
using Microsoft.Azure.Workflows.ServiceProviders.Abstractions;
using Microsoft.Azure.Workflows.ServiceProviders.WebJobs.Abstractions.Providers;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.WindowsAzure.ResourceStack.Common.Collections;
using Microsoft.WindowsAzure.ResourceStack.Common.Extensions;
using Microsoft.WindowsAzure.ResourceStack.Common.Storage.Cosmos;
using Microsoft.WindowsAzure.ResourceStack.Common.Swagger.Entities;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
{
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Azure.Workflows.ServiceProviders.Abstractions;
using Microsoft.Azure.Workflows.ServiceProviders.WebJobs.Abstractions.Providers;
using Microsoft.WindowsAzure.ResourceStack.Common.Collections;
using Microsoft.WindowsAzure.ResourceStack.Common.Extensions;
using Microsoft.WindowsAzure.ResourceStack.Common.Swagger.Entities;
using Newtonsoft.Json.Linq;
/// <summary>
/// This is the main class where you define all the operations and apis.
/// This is the service operation provider class where you define all the operations and apis.
/// </summary>
[ServiceOperationsProvider(Id = CosmosDbServiceOperationProvider.ServiceId, Name = CosmosDbServiceOperationProvider.ServiceName)]
public class CosmosDbServiceOperationProvider : IServiceOperationsTriggerProvider
[ServiceOperationsProvider(Id = CosmosDBServiceOperationProvider.ServiceId, Name = CosmosDBServiceOperationProvider.ServiceName)]
public class CosmosDBServiceOperationProvider : IServiceOperationsTriggerProvider
{
/// <summary>
/// The service name.
@ -40,7 +39,10 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
/// </summary>
private readonly InsensitiveDictionary<ServiceOperation> apiOperationsList;
public CosmosDbServiceOperationProvider()
/// <summary>
/// Constructor for Service operation provider.
/// </summary>
public CosmosDBServiceOperationProvider()
{
this.serviceOperationsList = new List<ServiceOperation>();
this.apiOperationsList = new InsensitiveDictionary<ServiceOperation>();
@ -56,6 +58,12 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
});
}
/// <summary>
/// Get binding connection information, needed for Azure function triggers.
/// </summary>
/// <param name="operationId"></param>
/// <param name="connectionParameters"></param>
/// <returns></returns>
public string GetBindingConnectionInformation(string operationId, InsensitiveDictionary<JToken> connectionParameters)
{
return ServiceOperationsProviderUtilities
@ -151,7 +159,7 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
}
},
{
"collectionName", new SwaggerSchema
"collectionName", new SwaggerSchema
{
Type = SwaggerSchemaType.String,
Title = "collection name",
@ -159,7 +167,7 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
}
},
{
"connectionStringSetting", new SwaggerSchema
"connectionStringSetting", new SwaggerSchema
{
Type = SwaggerSchemaType.String,
Title = "Connection String",
@ -192,19 +200,26 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
return "cosmosDBTrigger";
}
/// <summary>
/// Get operations.
/// </summary>
/// <param name="expandManifest">Expand manifest generation.</param>
public IEnumerable<ServiceOperation> GetOperations(bool expandManifest)
{
return expandManifest ? serviceOperationsList : GetApiOperations();
}
/// <summary>
/// Gets the operations.
/// Gets the api operations.
/// </summary>
private IEnumerable<ServiceOperation> GetApiOperations()
{
return this.apiOperationsList.Values;
}
/// <summary>
/// Get service operation.
/// </summary>
public ServiceOperationApi GetService()
{
return this.GetServiceOperationApi();
@ -235,8 +250,8 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
Properties = new ServiceOperationProperties
{
Api = this.GetServiceOperationApi().GetFlattenedApi(),
Summary = "receive document",
Description = "receive document",
Summary = "Receive document",
Description = "Receive document",
Visibility = Visibility.Important,
OperationType = OperationType.ServiceProvider,
BrandColor = 0x1C3A56,
@ -261,7 +276,7 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
BrandColor = 0xC4D5FF,
Description = "Connect to Azure Cosmos db to receive document.",
DisplayName = "Cosmos Db",
IconUri = new Uri("https://raw.githubusercontent.com/praveensri/LogicAppCustomConnector/main/ServiceProviders.CosmosDb.Extensions/icon.png"),
IconUri = new Uri("https://raw.githubusercontent.com/Azure//logicapps-connector-extensions/CosmosDB/src/CosmosDB/icon.png"),
Capabilities = new ApiCapability[] { ApiCapability.Triggers },
ConnectionParameters = new ConnectionParameters
{

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

@ -1,34 +1,31 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using Microsoft.Azure.Documents;
using Microsoft.Azure.WebJobs.Description;
using Microsoft.Azure.WebJobs.Host.Config;
using Microsoft.Azure.Workflows.ServiceProviders.Abstractions;
using Microsoft.WindowsAzure.ResourceStack.Common.Extensions;
using Microsoft.WindowsAzure.ResourceStack.Common.Json;
using Microsoft.WindowsAzure.ResourceStack.Common.Storage.Cosmos;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
{
using System.Collections.Generic;
using Microsoft.Azure.Documents;
using Microsoft.Azure.WebJobs.Description;
using Microsoft.Azure.WebJobs.Host.Config;
using Microsoft.Azure.Workflows.ServiceProviders.Abstractions;
using Microsoft.WindowsAzure.ResourceStack.Common.Json;
using Newtonsoft.Json.Linq;
/// <summary>
/// Service Provider class which injects all the service operation provider..
/// </summary>
[Extension("CosmosDbServiceProvider", configurationSection: "CosmosDbServiceProvider")]
public class CosmosDbServiceProvider : IExtensionConfigProvider
[Extension("CosmosDBServiceProvider", configurationSection: "CosmosDBServiceProvider")]
public class CosmosDBServiceProvider : IExtensionConfigProvider
{
/// <summary>
/// Register the service provider.
/// </summary>
/// <param name="serviceOperationsProvider"></param>
/// <param name="operationsProvider"></param>
public CosmosDbServiceProvider(ServiceOperationsProvider serviceOperationsProvider,
CosmosDbServiceOperationProvider operationsProvider)
public CosmosDBServiceProvider(ServiceOperationsProvider serviceOperationsProvider,
CosmosDBServiceOperationProvider operationsProvider)
{
serviceOperationsProvider.RegisterService(serviceName: CosmosDbServiceOperationProvider.ServiceName, serviceOperationsProviderId: CosmosDbServiceOperationProvider.ServiceId, serviceOperationsProviderInstance: operationsProvider);
serviceOperationsProvider.RegisterService(serviceName: CosmosDBServiceOperationProvider.ServiceName, serviceOperationsProviderId: CosmosDBServiceOperationProvider.ServiceId, serviceOperationsProviderInstance: operationsProvider);
}
/// <summary>

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

@ -1,18 +1,18 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Hosting;
using Microsoft.Extensions.DependencyInjection.Extensions;
[assembly: Microsoft.Azure.WebJobs.Hosting.WebJobsStartup(typeof(Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB.CosmosDbServiceProviderStartup))]
[assembly: Microsoft.Azure.WebJobs.Hosting.WebJobsStartup(typeof(Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB.CosmosDBStartup))]
namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
{
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Hosting;
using Microsoft.Extensions.DependencyInjection.Extensions;
/// <summary>
/// This is a start up function, the discovery of this extension is based upon IWebJobsStartup implementation.
/// In the function log file you should be able to see the log "Loading startup extension 'CosmosDbServiceProvider'"
/// </summary>
public class CosmosDbServiceProviderStartup : IWebJobsStartup
public class CosmosDBStartup : IWebJobsStartup
{
/// <summary>
/// The Configure method is invoked as initialization of the extension.
@ -20,8 +20,8 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
/// <param name="builder"></param>
public void Configure(IWebJobsBuilder builder)
{
builder.AddExtension<CosmosDbServiceProvider>();
builder.Services.TryAddSingleton<CosmosDbServiceOperationProvider>();
builder.AddExtension<CosmosDBServiceProvider>();
builder.Services.TryAddSingleton<CosmosDBServiceOperationProvider>();
}
}
}

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

@ -1,4 +1,7 @@
$extensionPath=$args[0]
$extensionPath=Split-Path -parent $PSCommandPath
$extensionPath = (get-item $extensionPath).parent.parent.FullName
write-host "Nuget extension path is $extensionPath"
$extensionName = "CosmosDB"
$extensionNameServiceProvider = $extensionName+"ServiceProvider"
@ -30,26 +33,30 @@ catch
write-host "func.exe not found"
}
# Add Nuget package to existing project
# 1. Add Nuget package to existing project
dotnet add package "Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB" --version 1.0.0 --source $extensionPath
$typeFullName = "Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB.CosmosDBServiceProviderStartup, $fullAssemlyName"
# 2. Update extensions.json under extension module
$typeFullName = "Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB.CosmosDBStartup, $fullAssemlyName"
$newNode = [pscustomobject] @{
name = $extensionNameServiceProvider
typeName = $typeFullName}
# 1. Update extensions.json under extension module
$a = Get-Content $extensionModulePath -raw | ConvertFrom-Json
if ( ![bool]($a.extensions.name -match $extensionNameServiceProvider))
$jsonContent = Get-Content $extensionModulePath -raw | ConvertFrom-Json
if ( ![bool]($jsonContent.extensions.name -match $extensionNameServiceProvider))
{
$a.extensions += $newNode
$a | ConvertTo-Json -depth 32| set-content $extensionModulePath
$jsonContent.extensions += $newNode
}
else
{
$jsonContent.extensions | % {if($_.name -eq $extensionNameServiceProvider){$_.typeName=$typeFullName}}
}
$jsonContent | ConvertTo-Json -depth 32| set-content $extensionModulePath
# 3. update dll in extension module.
$spl = Split-Path $extensionModulePath
Copy-Item $dll -Destination $spl

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

@ -3,21 +3,13 @@
namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB.Tests
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos;
using Microsoft.Azure.WebJobs.Host.TestCommon;
using Microsoft.Azure.Workflows.ServiceProviders.Abstractions;
using Microsoft.Extensions.Configuration;
using Microsoft.WindowsAzure.ResourceStack.Common.Json;
using Moq;
using Xunit;
using Xunit.Abstractions;
/// <summary>
/// Cosmos DB End2End tests.
/// Cosmos DB operation tests.
/// </summary>
public class CosmosDBOperationsTests
{
@ -41,7 +33,7 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB.Tests
[Fact]
public void OperationConnectionParametersTest()
{
var operations = new CosmosDbServiceOperationProvider();
var operations = new CosmosDBServiceOperationProvider();
var connectionParameters = operations.GetService().Properties.ConnectionParameters as ConnectionParameters;
var connectionStringParameters = new ConnectionStringParameters
{