Skip to content

Commit

Permalink
Added doc
Browse files Browse the repository at this point in the history
  • Loading branch information
mivano committed Jul 2, 2024
1 parent 1a8d3dd commit 78009d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,12 @@ jobs:
run-azure-cost-cli:
runs-on: ubuntu-latest
steps:
- name: Azure Login
uses: azure/login@v1
- name: Azure login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Install Azure Cost CLI
run: dotnet tool install -g azure-cost-cli
Expand All @@ -140,7 +142,7 @@ jobs:
```
The last step output the markdown to the Job Summary. This can be used to show the cost of the subscription in the workflow summary. Use it on a schedule to get for example a daily overview. Alternatively you can use the `-o json` parameter to get the results in JSON format and use it for further processing.
The last step outputs the markdown to the Job Summary. This can be used to show the cost of the subscription in the workflow summary. Use it on a schedule to get for example a daily overview. Alternatively you can use the `-o json` parameter to get the results in JSON format and use it for further processing.
## Available commands
Expand Down Expand Up @@ -604,6 +606,16 @@ azure-cost accumulatedCost -s 574385a9-08e9-49fe-91a2-27660d92b8f5 -o markdown >
Excluded in the above sample, but it will also include mermaidjs diagrams as well.
## Error handling
When the tool detects an exception, it will write this to the error stream and return with a -1. This can be used in scripts to detect if something went wrong. If you output using one of the formatters and want to save this to a file, you can use the `>` operator to redirect the output to a file. If you want to capture any errors as well, you can use the `2>&1` operator to redirect the error stream to the output stream. Or output it to a different file.
```bash
azure-cost accumulatedCost -o markdown > cost.md 2>error.log
```
> Breaking change in version 0.41.0: The tool will now return with a -1 when an error occurs. This is to make it easier to detect errors in scripts.
## Iterate over multiple subscriptions
Since the tool operates on a single subscription only, you will need to loop over multiple subscriptions yourself. You can do this by using the `az account list` command and then using the `--subscription` parameter to switch between subscriptions.
Expand Down
2 changes: 1 addition & 1 deletion src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
config.SetExceptionHandler((ex, resolver) =>
{
// Explicitly write to error output
Console.Error.Write(ex);
Console.Error.WriteLine(ex);
return -1;
});
Expand Down

0 comments on commit 78009d9

Please sign in to comment.