小编Jan*_*n_V的帖子

如何在运行时设置Azure WebJob队列名称?

我正在开发一个Azure WebJobs可执行文件,我想与多个Azure网站一起使用.每个网站都需要自己的Azure存储队列.

我看到的问题是ProcessQueueMessage需要将队列名称静态地定义为第一个参数的属性inputText.我宁愿让队列名称成为正在运行的Azure网站实例的配置属性,并且在启动时在运行时读取作业可执行文件.

有没有办法做到这一点?

azure-webjobs

41
推荐指数
1
解决办法
7149
查看次数

Roslyn没有引用System.Runtime

我正在开发一个项目,我们正在使用Roslyn为我们编译一些模板.现在,当我正在编译模板时,我收到了多个错误CompileResult.Diagnostics.

错误是:

(21,6): error CS0012: The type 'System.Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
(21,6): error CS0012: The type 'System.Type' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Run Code Online (Sandbox Code Playgroud)

看到这些错误,我认为我没有System.Runtime正确添加对程序集的引用.但是,在检查加载的组件后,这似乎是有序的.

private IEnumerable<MetadataReference> GetGlobalReferences()
{
    var assemblies = new [] 
        {
            typeof(System.Object).Assembly,                         //mscorlib
            typeof(System.Composition.ExportAttribute).Assembly,    //System.Composition (MEF)
            typeof(System.CodeDom.Compiler.CodeCompiler).Assembly,  //System.CodeDom.Compiler
        };

    var refs = …
Run Code Online (Sandbox Code Playgroud)

c# roslyn

22
推荐指数
3
解决办法
5888
查看次数

.NET - c# - 需要跨分区查询,但在DocumentDB数据访问时禁用了麻烦

我编写了以下代码来从DocumentDB中获取记录

private static void QueryDocuments1(DocumentClient client)
{

    IQueryable<SearchInput> queryable =
client.CreateDocumentQuery<SearchInput>(UriFactory.CreateDocumentCollectionUri(DocumentDBName, DocumentDBCollectionName))
        .Where(x => x.Receiver == "8907180");
    List<SearchInput> posts = queryable.ToList();
}
Run Code Online (Sandbox Code Playgroud)

并且它在代码行上显示以下错误 List<SearchInput> posts = queryable.ToList();

{"需要交叉分区查询但已禁用.请将x-ms-documentdb-query-enablecrosspartition设置为true,指定x-ms-documentdb-partitionkey,或修改查询以避免此异常.\ r \nActivityId:xxxxxx-xxxx -xxx-XXX-XXXXXXX"}

请帮帮我...

c# asp.net azure-cosmosdb

20
推荐指数
1
解决办法
1万
查看次数

使用端点路由时,不支持使用“ UseMvc”来配置MVC

我有一个Asp.Net core 2.2项目。

最近,我将版本从.net core 2.2更改为.net core 3.0 Preview8。更改之后,我看到以下警告消息:

使用端点路由时,不支持使用“ UseMvc”配置MVC。要继续使用“ UseMvc”,请在“ ConfigureServices”中设置“ MvcOptions.EnableEndpointRouting = false”。

我了解通过将其设置EnableEndpointRouting为false可以解决此问题,但是我需要知道什么是解决问题的正确方法,以及为什么端点路由不需要UseMvc()功能。

c# asp.net-mvc .net-core asp.net-core

19
推荐指数
8
解决办法
8811
查看次数

无法加载Microsoft.SqlServer.BatchParser或其中一个依赖项

我知道这个问题被问了很多次,我在谷歌上找到了很多关于这个问题的信息,但我仍然无法解决我的DEV PC上存在的问题:(
我在每一页上都有这个丑陋的错误信息(无法加载文件或程序集Microsoft.SqlServer.BatchParser).我按照许多互联网资源的建议安装了Microsoft SQL Server 2005管理对象集合,但没有帮助.然后我尝试安装Microsoft SQL Server 2008管理对象,但它说它无法安装,因为已经存在更新的版本(我安装了SQL Server 2008).
然后我去了GAC,发现以下几行:
Microsoft.SqlServer.BatchParser,Version = 10.0.0.0,Culture = neutral,PublicKeyToken = 89845dcd8080cc91,processorArchitecture = AMD64

Microsoft.SqlServer.BatchParser,Version = 9.0.242.0,Culture = neutral,PublicKeyToken = 89845dcd8080cc91,processorArchitecture = AMD64

Microsoft.SqlServer.BatchParser,Version = 10.0.0.0,Culture = neutral,PublicKeyToken = 89845dcd8080cc91,processorArchitecture = x86

Microsoft.SqlServer.BatchParser,Version = 9.0.242.0,Culture = neutral,PublicKeyToken = 89845dcd8080cc91,processorArchitecture = x86

Microsoft.SqlServer.BatchParserClient,Version = 10.0.0.0,Culture = neutral,PublicKeyToken = 89845dcd8080cc91,processorArchitecture = MSIL < - 版本9.0.242.0是否存在?

我已经花了大约半天的时间才找到一个没有成功的解决方案,当intellisense由于那个错误而无法工作时,使用VS非常糟糕.

我安装了VS 2010 SQL Express 2005和SQL Server 2008(参见配置屏幕截图) 在此输入图像描述

请帮帮我解决这个问题!谢谢.

sql-server visual-studio-2010 sql-server-2008

12
推荐指数
4
解决办法
3万
查看次数

Azure功能中的自定义绑定无法解析

我正在尝试为Azure Functions创建自己的自定义绑定.这项工作基于2篇关于此功能的维基文章:https: //github.com/Azure/azure-webjobs-sdk/wiki/Creating-custom-input-and-output-bindingshttps://github.com/天青/ WebJobsExtensionSamples

对于示例项目,我指的是Azure Functions/WebJobs绑定扩展示例项目.该项目基于.NET Framework 4.6.

我希望自己的自定义绑定能够与Azure Functions v2一起使用,所以我在所有项目中都使用NetStandard2.

在示例项目中,我看到在启动本地模拟器时加载了绑定扩展.

[3-1-2019 08:48:02]加载的绑定扩展'SampleExtensions'来自'reference by:Method ='FunctionApp.WriterFunction.Run',Parameter ='sampleOutput'.'

但是,在运行我自己的绑定扩展时,我从未看到此行出现.

我所做的是以下内容.首先,我创建了一个新属性.

[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
[Binding]
public class MySimpleBindingAttribute : Attribute
{
    /// <summary>
    /// Path to the folder where a file should be written.
    /// </summary>
    [AutoResolve]
    public string Location { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

还有一个相当简单的扩展类

public class MySimpleBindingExtension : IExtensionConfigProvider
{
    public void Initialize(ExtensionConfigContext context)
    {
        var rule = context.AddBindingRule<MySimpleBindingAttribute>();
        rule.BindToInput<MySimpleModel>(BuildItemFromAttribute);
    }

    private MySimpleModel BuildItemFromAttribute(MySimpleBindingAttribute …
Run Code Online (Sandbox Code Playgroud)

c# azure azure-functions

11
推荐指数
1
解决办法
958
查看次数

从文档中提取的 PartitionKey 与 CreateItemAsync 标头中指定的不匹配

我在使用 Microsoft.Azure.Cosmos 3.2.0 版时遇到了一些问题,

跑步时

await this.Container.CreateItemAsync<LogEntity>(logEntity, new PartitionKey("anythingIPutHere"));
Run Code Online (Sandbox Code Playgroud)

它抛出

Microsoft.Azure.Cosmos.CosmosException HResult=0x80131500
消息=响应状态代码不表示成功:400 子状态:1001 原因:(消息:{“错误”:[“从文档中提取的分区密钥与标题中指定的不匹配"]}

但如果我把

await this.Container.CreateItemAsync<LogEntity>(logEntity, new PartitionKey(logEntity.Id));
Run Code Online (Sandbox Code Playgroud)

它有效,并且是唯一有效的情况。

我也试过

  • 将分区键的值作为属性放入对象中;
  • 甚至指定了partitionKeyJSON 属性名称但没有成功;

我查看了 Microsoft 站点上的一些指南,似乎您可以将分区键指定为某个字符串,而不必是 id 或使用对象上的属性名称指定;那么为什么会这样呢?

azure-cosmosdb

11
推荐指数
1
解决办法
1万
查看次数

Azure Active Directory Graph Client 2.0

有人使用新的2.0版Azure AD Graph Client吗?

我昨天开始愚弄它但却无法让它发挥作用.将GraphConnection类标记为弃用,取而代之ActiveDirectoryClient.此外,突然之间它全部是Office 365,而我只是想在没有O365的情况下将我的试用限制在Azure Active Directory中.至少在您不想使用O365和O365 API工具时,很难找到文档.GitHub上的AD示例似乎也在更新,但代码仍在使用GraphConnection类.去搞清楚.

关于使用ActiveDirectory客户端的样本/指导并不多,所以目前使用的代码如下

public async Task<ActionResult> Index()
        {
            List<Exception> exceptions = new List<Exception>();
            ProfileViewModel model = new ProfileViewModel();
            string userObjectID = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
            AuthenticationContext authContext = new AuthenticationContext(SecurityConfiguration.Authority, new NaiveSessionCache(userObjectID));
            ClientCredential credential = new ClientCredential(SecurityConfiguration.ClientId, SecurityConfiguration.AppKey);

            try
            {
                var ServiceUri = new Uri(SecurityConfiguration.GraphUrl);
                ActiveDirectoryClient client = new ActiveDirectoryClient(ServiceUri, async () =>
                {
                    var result = await authContext.AcquireTokenSilentAsync(SecurityConfiguration.GraphUrl, credential, new UserIdentifier(userObjectID, UserIdentifierType.UniqueId));

                    return result.AccessToken;
                });
                try
                {

                    var users …
Run Code Online (Sandbox Code Playgroud)

graph active-directory azure

10
推荐指数
1
解决办法
4395
查看次数

在数据库上下文上执行Elastic Sc​​ale多分片查询

我正忙于在我正在进行的一个项目中实施新的Elastic Sc​​ale技术.这项技术似乎解决了我们在设计新应用程序基础时遇到的一些复杂问题.

到目前为止,这些示例看起来很棒,我正忙着在新创建的DAL中实现它.

对于我们的应用程序,我们不能仅依赖Azure中的Elastic Sc​​ale.应用程序必须能够在单个实例计算机上运行,​​也可以在内部运行.因此,我创建了以下代码来查询数据库,该数据库运行良好,也使用Elastic Sc​​ale.

public IEnumerable<AnEntity> All()
{
    var dbConnection = GetConnection();
    using (var context = new OurDatabaseContext(dbConnection))
    {
        var theEntities = context.EntityTable;
        return theEntities.ToArray();
    }
}
private IDbConnection GetConnection()
{
    var connectionInstance = connection[ConnectionStringNames.TheDatabase];
    var dbConnection = connectionInstance.Create();
    return dbConnection;
}
Run Code Online (Sandbox Code Playgroud)

connectionInstance通过IoC的配置,这将创造一个IDbConnection我们可以在使用OurDatabaseContext.一切都非常简单明了.

我面临的主要问题是MultiShardConnection由Elastic Sc​​ale提供并在示例中实现.

所以我的问题是,是否可以使用MultiShardConnection数据库上下文(如LINQ2SQL(我们正在使用)或EF).

如果没有,是唯一的解决方案,使用MultiShardConnectionMultiShardCommand?或者什么时候可以使用这样的功能?

c# entity-framework linq-to-sql azure-elastic-scale azure-sql-database

6
推荐指数
1
解决办法
1073
查看次数

通过Powershell创建标准定价层的Azure网站

我正在尝试修复我的持续部署方案,为此,Azure网站必须存在,并且能够在分段和生产之间进行交换.我们希望此网站在Standard定价层中运行.

我现在的脚本创建了一个新的ResourceGroup,托管计划,在创建这些脚本后,网站本身.我面临的问题是网站始终处于Free模式状态.我应该能够通过使用Set-AzureResourcecmdlet 来解决这个问题,但是这个问题告诉我应该指定Location.问题是这个特定的cmdlet没有Location参数.

Set-AzureResource : {
  "Error": {
    "Code": "LocationRequired",
    "Message": "The location property is required for this definition.",
    "Target": null,
    "Details": null
  }
}
Run Code Online (Sandbox Code Playgroud)

这是我用来创建所有资源的(简化)脚本:

#Create the resource group
New-AzureResourceGroup -Location $location -Name $resourceGroupName -Force

#Create the hosting plan
$hostingPlanParameters = @{"name" = $hostingPlanName; "sku" = "Standard"; "computeMode" = "Standard"; "workerSize" = "0"; "numberOfWorkers" = "1"}

New-AzureResource -ApiVersion 2014-04-01 -Name $hostingPlanName -ResourceGroupName $resourceGroupName `
                            -ResourceType Microsoft.Web/serverFarms -Location $location ` …
Run Code Online (Sandbox Code Playgroud)

powershell azure azure-web-sites azure-app-service-plans

6
推荐指数
1
解决办法
3580
查看次数