代码之家  ›  专栏  ›  技术社区  ›  Excelosaurus

限制AD组成员对某些Azure功能的访问

  •  0
  • Excelosaurus  · 技术社区  · 7 年前

    最近在我的客户机域中试用了Azure函数,我成功地部署了一个,并从一个.NET控制台应用程序调用了它。

    尽管花了好几个小时在谷歌上搜索,但我所能实现的只是激活AppService身份验证,如前所述 here

    我的控制台应用程序然后开始失败,代码401未经授权和“你没有权限查看此目录或页面”的响应内容-到目前为止,良好。。。然后我想我可以告诉Azure需要一个广告组的成员身份来调用这个函数,la WCF, 但是怎么做呢?

    下面是我调用函数的代码:

        private static async void CallMyTypedFunctionAsync()
        {
            var functionAddress = "https://[...].azurewebsites.net/api/MyTypedFunction";
            var requestDto = new DataContracts.MyTypedFunctionReqest { X = 6, Y = 7 };
    
            HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, functionAddress)
            {
                Content = new StringContent(JsonConvert.SerializeObject(requestDto), Encoding.UTF8, "application/json")
            };
    
            var httpClient = new HttpClient();
            var response = await httpClient.SendAsync(message);
            var responseContent = await response.Content.ReadAsStringAsync();
    
            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var responseDto = JsonConvert.DeserializeObject<DataContracts.MyTypedFunctionResponse>(responseContent);
                Console.WriteLine("CallMyTypedFunctionAsync's result: {0}", responseDto.Z); // 42
            }
            else
                Console.WriteLine("CallMyTypedFunctionAsync has failed. {0}: {1}", response.StatusCode, responseContent);
        }
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Tom Sun    7 年前

    正如Thomas提到的,你需要将你的广告同步到Azure广告目录。 如何做到这一点,你可以参考 Integrate your on-premises directories with Azure Active Directory

    有关如何访问受Azure AD保护的Azure功能,请参阅中功能部分的使用身份验证 Azure Functions and App Service Authentication

    推荐文章