Azure search for user, groups, or service principle by name or email address via Rest API or python module (MS Graph)? - azure

In azure when adding a user, group, or service principle to a role you can search by name and email address in the same search (screenshot below). When I look at the MS Graph APIs there are separate APIs for users, groups, and service principles (MS Graph API documentation links below). And it looks like the search options cannot be mixed (just display name or just email).
Does anyone know how to achieve a search like this using an Azure REST API. I'm curious if anyone knows what calls Azure is actually doing and if they are part of the published rest API? Or if one search is combining like multiple API calls which would be confusing since are paginated that would be hard to figure out what to display from which....
I'm building an app to add permissions and I'm trying to recreate a feature like this search.
Only way I can think of to achieve this now would be to select an option to search for either 'groups', 'users', or 'service principles'. Then another options to select search by 'email' or search by 'displayName' (but not both as the same search). This seems more clunky but technically ok.... but I'd rather do it like the azure screenshot below.
https://learn.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0&tabs=http
https://learn.microsoft.com/en-us/graph/api/group-list?view=graph-rest-1.0&tabs=http
https://learn.microsoft.com/en-us/graph/api/serviceprincipal-list?view=graph-rest-1.0&tabs=http

Microsoft Graph API provides batching functionality where you can batch multiple requests together and send them as a single request for processing. In your case, on the server-side (Graph API side) three requests will be processed but from your application you will be sending a single request and get a single response.
Your request would be something like:
{
"requests": [
{
"id": "1",
"method": "GET",
"url": "/users?$filter=<your-filter-criteria>"
},
{
"id": "2",
"method": "GET",
"url": "/groups?$filter=<your-filter-criteria>"
},
{
"id": "3",
"method": "GET",
"url": "/servicePrincipals?$filter=<your-filter-criteria>"
}
]
}
You can learn more about the batching capability in Microsoft Graph API here: https://learn.microsoft.com/en-us/graph/json-batching.

So the batching answer was not exactly what I wanted but something really cool that I'll likely end up using in the future!
Since batching could get ugly with the paging results since say I want 30 total results (so i set paging to 10,10,10) then if one gives 10 and has nextlink and the next gives 0 and the last give 5. I now have 15 results to display but paging with the other and the sorting of results after the next could throw results earlier. It might just be weird and I don't have time to think it through.
I just ended up doing a drop down for users, groups, and service principals. And you have to search separate. Not as cool as how MS does it internally but its consistent, predictable, and works.

Related

Binance API list all symbols with their names from a public endpoint

I've integrated the Binance API in my project to show a list of all supported symbols and their corresponding icon. However, I'm unable to fetch the symbols name/description.
For instance, I can fetch BTC-EUR, but I can't fetch 'Bitcoin' or similar through a public endpoint. At least, I haven't found the endpoint so far.
For now, I'm using a private endpoint (which is behind authentication) at /sapi/v1/margin/allAssets. This returns me the name/description for each symbol, but as you can imagine I want to prevent usage of private API tokens on fetching public information
{
"assetFullName": "Bitcoin", <----- This is what I'm looking on a public endpoint
"assetName": "BTC",
"isBorrowable": true,
"isMortgageable": true,
"userMinBorrow": "0.00000000",
"userMinRepay": "0.00000000"
}
So, my question is whether there is a public endpoint available to fetch the same information? Right now, I'm using the endpoint /api/v3/exchangeInfo to retrieve the available symbols on the exchange, but this response hasn't got the name/description of the symbol in it...
"symbols": [
{
"symbol": "ETHBTC",
"status": "TRADING",
"baseAsset": "ETH",
"baseAssetPrecision": 8,
"quoteAsset": "BTC",
"quotePrecision": 8,
"quoteAssetPrecision": 8,
"orderTypes": [
"LIMIT",
"LIMIT_MAKER",
"MARKET",
"STOP_LOSS",
"STOP_LOSS_LIMIT",
"TAKE_PROFIT",
"TAKE_PROFIT_LIMIT"
],
"icebergAllowed": true,
"ocoAllowed": true,
"isSpotTradingAllowed": true,
"isMarginTradingAllowed": true,
"filters": [
//These are defined in the Filters section.
//All filters are optional
],
"permissions": [
"SPOT",
"MARGIN"
]
}
]
I've already looked for public endpoints about listing assets, as that's usually the namespace other exchanges return this information for, but I can't find such an endpoint in the documentation of the Binance API
I ran into this same frustrating mess. Binance US doesn't allow the /sapi/v1/margin/allAssets because MARGIN permissions aren't granted for US users (returns an 'Invalid Api-Key ID').
There is nothing else available in their SPOT accounts that gives this data.
What I ended up doing was pulling the data from CoinMarketCap via
https://pro-api.coinmarketcap.com/v1/cryptocurrency/map?CMC_PRO_API_KEY=<your-API-key>
Check their API authentication documentation.
PROS:
It's free w/ the Basic account (you will need an account and an active API key - 5 minutes, tops)
CONS:
It's NOT a standard (there isn't one, that I can tell). It will work fine for BTC, but take a look at the symbol HOT -- there's a few of them. You will have to manually curate those to match Binance (I persisted the CMC Unique ID in addition to the symbol & name). It sucks, but Binance doesn't give basic data like the name of the currency, which is absurd.
You can
Proxy the private enpoint through your app, so that your API key stays hidden from your users
Use another data source such as Coinmarketcap as already mentioned in another answer
Query undocumented public endpoints (list with just name per each symbol, detail with name and description) that they use on the web app and are likely to change
However there is currently no direct way to get a currency name and symbol through an officially documented public Binance API endpoint without authorization.

Can Azure batch transcription results be directed to a non-public url

I would like to use the Microsoft Azure Cognitive Service Speech-to-text. It offers a REST API, which I succesfully have used. I can point to an Azure blob storage using a SAS URI, and the files in the container are transcribed.
My problem is, that when I try to retrieve the transcription results from the API, they are published to a public url. Since voice data can be sensitive, I would like to keep the results stored privately. Is there any way to do this?
I does not seem like it is an option in the API schema, although you can set a destinationContainerUrl. I have tried to set the destinationContainerUrl, but the result does not appear in the container.
I have only used the API reference, which is why I am not posting any code.
You've found the correct option. Using destinationContainerUrl will write the results into this container. Make sure you provide a container SAS which allows listing and writing.
When the job succeeds, the results should be there. Please check that status of your job, maybe it was set to failed.
Documentation about transcriptions:
https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/batch-transcription
If the job succeeds and the files are not on this container, please let us know the $.self link of the job and the creation time, to help us gathering the logs.
Ok. So the solution was super simple. I just did the post request json wrong. destinationContainerUrl needs to be under properties, as shown below:
{"contentUrls": ["LINK-TO-BLOB-SAS-URI-TOKEN"],
"properties": {
"diarizationEnabled": false,
"wordLevelTimestampsEnabled": false,
"punctuationMode": "DictatedAndAutomatic",
"profanityFilterMode": "Masked",
"destinationContainerUrl": "LINK-TO-BLOB-SAS-URI-TOKEN"
},
"locale": "en-US",
"displayName": "Transcription from blob to blob"
}

Get route url for a http triggered functions in an ARM template

I'm trying to figure out how to get the route for an HTTP triggered Azure Function within an ARM template.
Thanks to a blog post I managed to find out the listsecret command, but when trying to execute this action via powershell, the output doesn't give me the trigger_url I was expecting. The URL does not comply with the configured route of the function, and shows the default trigger if no route would have been configured.
Any way I can get a hold of the configured route instead since I can't seem to use the trigger_url.
My configured route has got parameters in the path as well, e.g.:
{
"name": "req",
"type": "httpTrigger",
"direction": "in",
"authLevel": "function",
"methods": [
"POST"
],
"route": "method/{userId}/{deviceId}"
}
The output of listsecrets is:
trigger_url: https://functionapp.azurewebsites.net/api/method?code=hostkey
Is there any other way to extract the host key and route?
Try playing with the API version, but I would suspect that this is not possible as of now.
Currently, the only way to get the route is by reading the function.json file and parsing that information out, which you can do by using Kudu's VFS API.
For the keys, I would actually recommend using the key management APIs instead of listSecrets. As the latter is meant to address a small set of scenarios (primarily to enable some internal integrations) where the key management API more robust API and will continue to work with different secret storage providers (e.g. Azure Storage, which is what is used when slots are enabled and will eventually become the default).

How to filter SmartCollections via Shopify API?

I need to get only those SmartCollections that are imitating some kind of category of products e.g. Pants, Shirts, Shoes. But there is also collections like "All Products" or "Available on local store". What I need to get via API are only those spesific categories and nothing else.
So is there any way to set some kind of metafield or alternative to SmartCollections so I could filter via API only collections I need?
Of course one(and really bad) way to do this is to hard code list of not wanted collections, but this solution isn't very dynamic :/
I am using this package froatsnook:shopify from atmospherejs.com.
Here is Shopify's API documentation about SmartCollections: SmartCollection
Okay, I managed to do this eventhough API disagrees with me. With this Chrome extension you can use metafields also with SmartCollections: http://shopifyfd.com/
And then you just have to create new function for this new endpoint via build in functionality provided by froatsnook:shopify like this:
Shopify.API.define({
"name": "getSmartCollectionMetafieldsById",
"method": "GET",
"path": "/admin/smart_collections/#{collection_id}/metafields.json",
"returns": "metafields",
"description": "Get a single smart_collection metafields by its ID"
});
And voilá! Now you can include/exclude SmartCollections via API by using metafields!

Azure Logic App - Twitter Connector Issues

I have a Logic App with Twitter connector and a Dropbox connector. The latter has repeater, which loops over the Twitter body and upload a text file in each iteration with Tweet_ID as file name. The Dropbox connector many times returns conflict errors, it seems Tweet connector keeps returning same tweets again and again, which had been already processed, which results in duplicate file names.
When I look at the output of the Dropbox connector, below is the body it returns.
"body": {
"status": 409,
"source": "api-content.dropbox.com",
"message": "conflict_file"
}
You have probably seen this page https://azure.microsoft.com/sv-se/documentation/articles/app-service-logic-use-logic-app-features/ where they show how to do this.
Have you checked that you don't supply the same Tweet_ID several times? The logic app json format it a bit tricky right now, with not so much documentation.
/dag
You are right. The twitter connector doesn't "remember" the tweets that are returned from a search. It will return the same again. (Just to be clear. We are discussing the Twitter Connector Action Search Tweets.)

Resources