带QueueTrigger的Azure功能:是否可以仅配置存储帐户网址并使用托管身份访问队列?

如何解决带QueueTrigger的Azure功能:是否可以仅配置存储帐户网址并使用托管身份访问队列?

我已经定义了此功能

[FunctionName("My_QueueTrigger")]
public Task RunAsync([QueueTrigger("my-queue-name",Connection = "AzureWebJobsstorage")] string text)
{
  // code here...
}

AzureWebJobsstorage(在Azure上)包含以下内容"DefaultEndpointsProtocol=https;AccountName=my-storage-account;AccountKey=mykey;EndpointSuffix=core.windows.net"

(请注意,对于本地开发,该值为"UseDevelopmentStorage=true"。)

我的问题是,是否也可以在此处定义存储帐户名称,例如"https://my-storage-account.queue.core.windows.net",然后使用Azure函数中的托管身份(具有 Processor 权限)来读取/触发在邮件上。

解决方法

我认为您的要求是不可能的。

连接到存储的基础代码已封装在WebJob包中,该包作为成员包包含在整个功能的扩展包中。您必须修改基础代码才能实现所需的功能。

检查queuetrigger属性的源代码:

using System;
using System.Diagnostics;
using Microsoft.Azure.WebJobs.Description;

namespace Microsoft.Azure.WebJobs
{
    /// <summary>
    /// Attribute used to bind a parameter to an Azure Queue message,causing the function to run when a
    /// message is enqueued.
    /// </summary>
    /// <remarks>
    /// The method parameter type can be one of the following:
    /// <list type="bullet">
    /// <item><description>CloudQueueMessage</description></item>
    /// <item><description><see cref="string"/></description></item>
    /// <item><description><see cref="T:byte[]"/></description></item>
    /// <item><description>A user-defined type (serialized as JSON)</description></item>
    /// </list>
    /// </remarks>
    [AttributeUsage(AttributeTargets.Parameter)]
    [DebuggerDisplay("{QueueName,nq}")]
    [ConnectionProvider(typeof(StorageAccountAttribute))]
    [Binding]
    public sealed class QueueTriggerAttribute : Attribute,IConnectionProvider
    {
        private readonly string _queueName;

        /// <summary>Initializes a new instance of the <see cref="QueueTriggerAttribute"/> class.</summary>
        /// <param name="queueName">The name of the queue to which to bind.</param>
        public QueueTriggerAttribute(string queueName)
        {
            _queueName = queueName;
        }

        /// <summary>Gets the name of the queue to which to bind.</summary>
        public string QueueName
        {
            get { return _queueName; }
        }

        /// <summary>
        /// Gets or sets the app setting name that contains the Azure Storage connection string.
        /// </summary>
        public string Connection { get; set; }
    }
}

您可以找到源代码,它告诉我们我们需要提供连接字符串而不是存储URL。

下载source code of webjobs package,并检查queuetrigger的源代码,您会发现该源代码未实现所需的代码。您无法告诉该功能您要使用MSI,并且它无法为您提供使用此功能的任何方式。

简而言之,源代码无法实现您的想法。除非您修改源代码的基础实现,重新编译并导入程序包,否则是不可能的。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?