AzureGraph/README.md

63 строки
3.0 KiB
Markdown
Исходник Постоянная ссылка Обычный вид История

2019-08-03 06:38:15 +03:00
# AzureGraph <img src="man/figures/logo.png" align="right" width=150 />
2019-03-14 19:09:24 +03:00
2019-04-01 04:35:42 +03:00
[![CRAN](https://www.r-pkg.org/badges/version/AzureGraph)](https://cran.r-project.org/package=AzureGraph)
![Downloads](https://cranlogs.r-pkg.org/badges/AzureGraph)
2020-10-11 03:38:53 +03:00
![R-CMD-check](https://github.com/Azure/AzureGraph/workflows/R-CMD-check/badge.svg)
2019-04-01 04:35:42 +03:00
2023-09-06 10:23:39 +03:00
A simple interface to the [Microsoft Graph API](https://learn.microsoft.com/en-us/graph/overview). The companion package to [AzureRMR](https://github.com/Azure/AzureRMR) and [AzureAuth](https://github.com/Azure/AzureAuth).
2019-03-19 01:47:36 +03:00
2019-03-25 10:05:58 +03:00
Microsoft Graph is a comprehensive framework for accessing data in various online Microsoft services. Currently, this package aims to provide an R interface only to the Azure Active Directory part, with a view to supporting interoperability of R and Azure: users, groups, registered apps and service principals. Like AzureRMR, it could potentially be extended to cover other services.
2019-03-14 19:09:24 +03:00
2019-08-03 06:38:15 +03:00
The primary repo for this package is at https://github.com/Azure/AzureGraph; please submit issues and PRs there. It is also mirrored at the Cloudyr org at https://github.com/cloudyr/AzureGraph. You can install the development version of the package with `devtools::install_github("Azure/AzureGraph")`.
2019-03-14 19:09:24 +03:00
## Authentication
2021-05-31 07:02:08 +03:00
The first time you authenticate with a given Azure Active Directory tenant, you call `create_graph_login()` and supply your credentials. R will prompt you for permission to create a special data directory in which to save the obtained authentication token and AD Graph login. Once this information is saved on your machine, it can be retrieved in subsequent R sessions with `get_graph_login()`. Your credentials will be automatically refreshed so you don't have to reauthenticate.
2019-03-14 19:09:24 +03:00
2021-05-31 07:02:08 +03:00
See the "Authentication basics" vignette for more details on how to authenticate with AzureGraph.
2019-03-14 19:09:24 +03:00
## Sample workflow
2019-03-16 13:47:03 +03:00
AzureGraph currently includes methods for working with registered apps, service principals, users and groups. A `call_graph_endpoint()` method is also supplied for making arbitrary REST calls.
2019-03-14 19:09:24 +03:00
```r
library(AzureGraph)
# authenticate with AAD
# - on first login, call create_graph_login()
# - on subsequent logins, call get_graph_login()
gr <- create_graph_login()
# list all users in this tenant
gr$list_users()
# list all app registrations
gr$list_apps()
2019-03-19 01:47:36 +03:00
# my user information
me <- gr$get_user("me")
# my groups
2019-03-25 10:05:58 +03:00
head(me$list_group_memberships())
# my registered apps
me$list_owned_objects(type="application")
2019-03-19 01:47:36 +03:00
# register a new app
2019-11-08 00:02:24 +03:00
# by default, this will have a randomly generated strong password with duration 2 years
2019-03-14 19:09:24 +03:00
app <- gr$create_app("AzureR_newapp")
# get the associated service principal
2019-03-16 13:47:03 +03:00
app$get_service_principal()
2019-03-25 10:05:58 +03:00
# using it in conjunction with AzureRMR RBAC
AzureRMR::get_azure_login()$
get_subscription("sub_id")$
get_resource_group("rgname")$
add_role_assignment(app, "Contributor")
2019-03-14 19:09:24 +03:00
```
---
2019-08-03 06:38:15 +03:00
<p align="center"><a href="https://github.com/Azure/AzureR"><img src="https://github.com/Azure/AzureR/raw/master/images/logo2.png" width=800 /></a></p>