-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Hello,
Using a system or user assigned identity in combination with get_managed_token gives a 404 error. Could not get the function working from within an app service running a Shiny app using a managed identity to access a storage account. AzureAuth seems to make the wrong API call at and endpoint /MSI/token/token that does not exist and hence returns 404 since it should be http://{endpoint}/MSI/token. From within a VM for local development obtaining a token using managed identity using AzureAuth works as expected.
Current workaround for the app service is to create the API call manually instead of using AzureAuth for a system assigned MI reading data from a storage account in a Shiny app hosted in App Services.
library(httr)
library(AzureStor)
# Fetch / set variables for API call within app service running Shiny app running on Shiny server
api_version <- "2019-08-01" ## Might work with newer versions as well
mi_endpoint <- Sys.getenv("MSI_ENDPOINT")
mi_secret <- Sys.getenv("MSI_SECRET")
resource <- "https://storage.azure.com"
storage_account <- "https://<storageaccountname>.blob.core.windows.net"
container_name <- "mycontainer"
headers <- c(
`X-IDENTITY-HEADER` = mi_secret
)
## Fetch managed identity token
res <- GET(url = paste0(mi_endpoint, '?resource=', resource, "&api-version=", api_version), add_headers(.headers=headers))
mi_token <- content(res)$access_token
## Connect to storage account using MI
ad = storage_endpoint(storage_account, token = mi_token)
cont = storage_container(ad, container_name)
kmcoding and ciasom
Metadata
Metadata
Assignees
Labels
No labels