小编Roh*_*gal的帖子

如何在Azure中列出Virtual Machines Classic

我想以编程方式列出和控制Azure中的经典(旧版)虚拟机.对于托管它没有问题,有库和其余的API正在工作,但一旦我调用旧API列出经典,我得到403(禁止).

代码好吗?我是否需要在其他地方管理旧API的凭据?

我的代码在这里:

static void Main(string[] args)
{
    string apiNew = "https://management.azure.com/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxx/providers/Microsoft.Compute/virtualMachines?api-version=2018-06-01";
    string apiOld = "https://management.core.windows.net/xxxxxxxxxxxxxxxxxxxxxxxx/services/vmimages"

    AzureRestClient client = new AzureRestClient(credentials.TenantId, credentials.ClientId, credentials.ClientSecret);

    //OK - I can list the managed VMs.         
    string resultNew = client.GetRequestAsync(apiNew).Result;

    // 403 forbidden
    string resultOld = client.GetRequestAsync(apiOld).Result;        
}

public class AzureRestClient : IDisposable
{
    private readonly HttpClient _client;

    public AzureRestClient(string tenantName, string clientId, string clientSecret)
    {
        _client = CreateClient(tenantName, clientId, clientSecret).Result;
    }

    private async Task<string> GetAccessToken(string tenantName, string clientId, string clientSecret)
    {
        string …
Run Code Online (Sandbox Code Playgroud)

c# rest credentials azure azure-active-directory

5
推荐指数
1
解决办法
524
查看次数

Azure:服务主体ID与应用程序ID

根据此文档:应用程序和服务主体显然是两个不同的事物。应用程序是全局标识,服务主体是每个租户/ AAD

但是本文档本堆栈溢出问题 表明它们是相同的。

为了使其更加混乱,当我使用Graph API(来自第一个参考文献)并按我的应用程序名称查询时:

https://graph.windows.net/<tenantName>/applications?api-version=1.6&$filter=displayName eq '<Apllication Name>'
Run Code Online (Sandbox Code Playgroud)

我看到一个对象ID,一个应用程序ID(我认为是相同的),但Json中没有服务主体ID

AppID和ServicePrincipalID(以及ClientID,ObjectID)之间是什么关系?谢谢。

azure-active-directory azure-ad-graph-api azure-security azure-authentication

5
推荐指数
1
解决办法
4182
查看次数

如何将过滤器与 az ad 应用程序一起使用进行批量删除

我正在尝试使用 AZ AD CLI 删除许多具有类似属性的应用程序。我找不到任何好的例子--filter

试图做这样的事情:

ad az app list --filter (displayName like 'stack') | ad az app delete
Run Code Online (Sandbox Code Playgroud)

任何指针都非常感谢。

azure azure-active-directory azure-cli

5
推荐指数
1
解决办法
3235
查看次数

使用 Get-AzureAdUser 有没有办法从源“Windows 服务器广告”中拉回所有用户?

我有一个包含大约 20 万用户的目录。我需要撤回来自本地 AD 的所有用户。这当然会排除多个源来宾用户。我必须使用源,因为并非所有用户都有用户类型。

如果有一种方法可以搜索 Department 不等于 null 也可以,但它似乎不是 odata 过滤器标准的一部分。

Get-AzureADUser -Filter "Department eq ''"  | select DisplayName,`
    UserPrincipalName,Mail,creationType,AccountEnabled,Department
Run Code Online (Sandbox Code Playgroud)

azure azure-powershell azure-active-directory

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

如何为Azure Function应用v2.0设置无限超时

我有一个运行时间很长的进程,该进程使用Azure Function App(针对长时间运行的进程)托管(针对v2.0)。之前它的目标是v1.0运行时,所以我没有遇到任何函数超时问题。

但是现在在将运行时更新为目标v2.0之后,我无法找到任何方法来将函数超时设置为Infinite(与v1.0一样)。

有人可以帮我吗?

timeout azure azure-functions

3
推荐指数
2
解决办法
2413
查看次数

以编程方式从 Azure AD 获取用户组和角色

我是天蓝色 AD 的新手。

我有一个第三方 API,它为我提供了 userId。我编写了一个 .NET Core API,它应该采用此用户 ID 并获取该特定用户的角色和组。

我读过有关 microsoft graph API 的内容。不确定这在我的场景中是否有用。

还有其他方法可以以编程方式访问 AD 用户的角色和组吗?

azure azure-active-directory microsoft-graph-api

3
推荐指数
1
解决办法
5846
查看次数

如何使用逻辑应用以编程方式在 Azure AD 中注册应用程序?

我想使用 Azure Logic App 构建应用程序注册流程(用于自动化)

如何在 Azure AD 中自动注册应用程序?进行 REST API 调用应该简单直接,有人知道如何进行应用程序注册的 POST 吗?

很少有例子将不胜感激。

参考: https: //learn.microsoft.com/en-us/previous-versions/azure/ad/graph/api/entity-and-complex-type-reference#application-entity

除了 Azure 逻辑应用程序支持的 REST API 之外,任何其他方式也非常受欢迎!

azure azure-active-directory azure-logic-apps

2
推荐指数
1
解决办法
3138
查看次数

如何获取为特定用户分配的 Azure 应用服务托管服务标识的令牌?

我正在尝试获取特定用户定义身份的 msi 令牌。我们的应用服务有 2 个用户定义的身份,我想要一个代表用户分配的身份之一的令牌。

这是代码:

        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(
            "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/&object_id=<ObjectId>&client_id=<clientId>");

        req.Headers["Metadata"] = "true";
        req.Method = "GET";

        try
        {
            // Call /token endpoint
            HttpWebResponse response = (HttpWebResponse)req.GetResponse();

            // Pipe response Stream to a StreamReader, and extract access token
            StreamReader streamResponse = new StreamReader(response.GetResponseStream());
            string stringResponse = streamResponse.ReadToEnd();
            Dictionary<string, string> list =
                 JsonConvert.DeserializeObject<Dictionary<string, string>>(stringResponse);
            string accessToken = list["access_token"];

            System.IO.File.WriteAllText(@".\Log.txt", accessToken);
        }
        catch (Exception e)
        {
            string errorText = String.Format("{0} \n\n{1}", e.Message, e.InnerException != null ? e.InnerException.Message : "Acquire token failed");
            System.IO.File.WriteAllText(@".\Log.txt", …
Run Code Online (Sandbox Code Playgroud)

azure azure-active-directory azure-web-app-service azure-managed-identity

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

如何通过Azure AD检查用户是否在AD组中?

设置规格

  • .NET 4.5.1 MVC项目
  • 项目包含.aspx文件(旧版)
  • 当前,用户Azure AD通过Cookie进行身份验证。
  • Azure门户(通过应用程序注册)配置为“隐式授予-ID令牌”和“仅此组织目录中的帐户”
  • 本地AD组被上推到Azure AD。

Startup.cs配置

// COOKIES: Tells it to use cookies for authentication.
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
    CookieManager = new SystemWebCookieManager()
});

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions()
{
    ClientId = ClientID,
    Authority = Authority,
    PostLogoutRedirectUri = PostLogoutRedirectUri,
    Notifications = new OpenIdConnectAuthenticationNotifications()
    {
        AuthenticationFailed = PrincipalService.OnAzureAuthenticationFailure,
        AuthorizationCodeReceived = (AuthorizationCodeReceivedNotification notification) =>
        {
            var username = notification.AuthenticationTicket.Identity.Name.Split('#').LastOrDefault();
            var emailAddress = notification.AuthenticationTicket.Identity.Claims.FirstOrDefault(x => x.Type.Contains("emailaddress"))?.Value;
            Logger.Log(Level.Auth, $"Azure login success! Username: '{username}' Email: '{emailAddress}'.");
            return Task.FromResult(0);
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

在进行此设置后,如何检查当前登录的用户是否在特定的AD组中? …

azure-active-directory microsoft-graph

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