通过编程方式找到Azure函数的区域

发布于 2025-02-07 01:15:25 字数 141 浏览 1 评论 0原文

我有一个使用托管服务身份身份验证令牌来调用Azure函数API的服务。我希望能够根据代码的区域调用正确的区域Azure函数。因此,例如,如果我通过的区域是useast2,则我需要使用C#编程中驻留在useast2区域中的Azure函数。我该怎么做?

谢谢

I have a service that invokes the azure function API using the Managed Service Identity authentication token. I want to be able to invoke the correct regional azure function based on the region from code. So for example, if the region I pass is useast2, I need to invoke the azure function that resides in useast2 region programmatically using C#. How can I do this?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只是偏爱你 2025-02-14 01:15:26

您可以将此代码线用于查找区域名称。 region_name应用程序的名称。

Environment.GetEnvironmentVariable("REGION_NAME")

就我而言,我正在创建一个使用以下代码查找区域的WebJob。

using System;
using System.Threading;

namespace CheckErrorOrLog
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Azure web job Start");
            for(int i = 0; i < 10; i++)
            {
                Console.WriteLine(i);
                Thread.Sleep(2 * 60 * 1000);
                Console.WriteLine(Environment.GetEnvironmentVariable("REGION_NAME"));
            }
        }
    }
}

输出

“在此处输入图像说明”
您可以在这些 Microsoft文档应用程序环境

You can use this line of code for find the regions name. REGION_NAME regions name of the app.

Environment.GetEnvironmentVariable("REGION_NAME")

In my case, I am create a webjob for find the region using below code.

using System;
using System.Threading;

namespace CheckErrorOrLog
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Azure web job Start");
            for(int i = 0; i < 10; i++)
            {
                Console.WriteLine(i);
                Thread.Sleep(2 * 60 * 1000);
                Console.WriteLine(Environment.GetEnvironmentVariable("REGION_NAME"));
            }
        }
    }
}

Output

enter image description here
You can find other environment variable on these Microsoft Document App Environment

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文