是否应将托管服务身份用于从控制台应用程序访问Azure应用程序服务

时间:2019-04-22 13:38:40

标签: c# azure azure-web-app-service

我有一个在企业内部运行的控制台应用程序,需要作为App Service Web API进行访问。什么是处理身份验证的最佳方法。我尝试通过AD注册该应用程序,但似乎仍然看不到该应用程序服务。我尝试了以下代码,但是我不确定这是否是正确的API。

* {
  margin: 0px;
  padding: 0px;
}

body {
  margin: 50px;
  font-size: 16px;
}

ul {
  margin: 0px 0px 0px 20px;
  list-style: none;
  line-height: 2;
}

li {
  position: relative;
}

li::after {
  position: absolute;
  left: -10px;
  bottom: -7px;
  content: '';
  display: block;
  border-left: 1px solid red;
  height: 100%;
}

li::before {
  position: absolute;
  left: -10px;
  top: -10px;
  content: '';
  display: block;
  border-left: 1px solid red;
  height: 32px;
  border-bottom: 1px solid red;
  width: 10px;
}

li:last-child::after {
  display: none;
}

.node {
  display: inline-block;
  border: 1px solid red;
  padding: 5px;
  margin-bottom: 10px;
}

这无法说明未定义范围。看起来就像在Azure中一样。

1 个答案:

答案 0 :(得分:0)

首先,您需要为您的App身份创建角色分配。然后,您可以从身份获取访问令牌。该代码将如下所示:

int

不要忘记将对Microsoft.Azure.Services.AppAuthentication的引用以及任何其他必要的NuGet包添加到您的应用程序。有关更多详细信息,请参见Obtaining tokens for Azure resources with App MSI

相关问题