azure_memo
Simple useful commands to run against Azure
Installation tricks
- instruct
pip
to use the system certificate store instead of the "incomplete" bundled cacert that comes with it by installingpip-system-certs
pip install pip-system-certs
Login to Azure & switch subscription
Log in
az login
List your subscriptions
az account list --output table
Switch subscription
az account set --subscription <name or id>
Management and Governance
(Resource) Groups
List resource groups
az group list -o table
Compute
Function Apps
- List all FunctionApps:
az functionapp list -o table
DevOps
Monitor
Log Analytics
- Find the Log Analytics Workspace ID you want to query
- Run a specific query:
az monitor log-analytics query -w 7893d280-08de-4763-a795-b36f4432fddd --analytics-query "AppTraces | where TimeGenerated > ago(10m) "
az monitor log-analytics query -w 7893d280-08de-4763-a795-b36f4432fddd --analytics-query "AppTraces | where TimeGenerated > ago(10m) | where OperationName == 'func_nasa_hdl_ingestion' "
az monitor log-analytics query -w 7893d280-08de-4763-a795-b36f4432fddd --analytics-query "AppTraces | where TimeGenerated > ago(10m) | where OperationName != 'func_nasa_hdl_ingestion' "
Application Insights
- Find the (Application Insights) app attached to the resource you are interested in.
- Click the
JSONview
and find theAppID
of the app (something like14f0953-ad40-42c5-b29d-debc616b215fd
) - Search for the metric you are interested in among the huge list provided by
get-metadata
(.venv) λ az monitor app-insights metrics get-metadata --app 14215fd3-ad40-42c5-b29d-def095bc616b | grep "requests"
"performanceCounters/requestsInQueue": {
"displayName": "ASP.NET requests in application queue",
"performanceCounters/requestsPerSecond": {
"requests/count": {
"displayName": "Server requests",
"requests/duration": {
"requests/failed": {
"displayName": "Failed requests",
- show the metric's data on a given time interval (very badly documented by Microsoft)
(.venv) λ az monitor app-insights metrics show --app 14215fd3-ad40-42c5-b29d-def095bc616b --metric requests/count --start-time 2022-09-12 --end-time 2022-09-13
{
"value": {
"end": "2022-09-12T22:00:00+00:00",
"interval": null,
"requests/count": {
"sum": 280
},
"segments": null,
"start": "2022-09-11T22:00:00+00:00"
}
}
(.venv) λ az monitor app-insights metrics show --app 14215fd3-ad40-42c5-b29d-def095bc616b --metric requests/count --start-time 2022-09-12 01:00:00 --end-time 2022-09-12 02:00:00
{
"value": {
"end": "2022-09-12T00:00:00+00:00",
"interval": null,
"requests/count": {
"sum": 12
},
"segments": null,
"start": "2022-09-11T23:00:00+00:00"
}
}