-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cost Management Export for custom timeframe fails with 401 Unauthorized and points to trafficmanager.net endpoint #575
Comments
Hi @BeeDeeBePope , Thank you for taking time to report this issue! This issue is caused by the upstream API, and was fixed in #184 (comment). Please double confirm that in the automation whether the azapi provider version is above 1.9.0. |
Hi @ms-henglu,
|
Thanks @BeeDeeBePope - I couldn't reproduce this issue locally and I tried authenticate with Azure by azure cli and service principal. Here's the config: resource "azapi_resource" "resourceGroup" {
type = "Microsoft.Resources/resourceGroups@2021-04-01"
name = "henglu815"
location = "westus"
body = {} # Resource group does not require additional properties in the body
}
resource "azurerm_storage_account" "test" {
name = "henglu815"
resource_group_name = azapi_resource.resourceGroup.name
location = azapi_resource.resourceGroup.location
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_storage_container" "test" {
name = "henglu815"
storage_account_name = azurerm_storage_account.test.name
}
resource "azapi_resource" "cost_management_export" {
type = "Microsoft.CostManagement/exports@2022-10-01"
name = "henglu815"
parent_id = azapi_resource.resourceGroup.id
body = {
properties = {
schedule = {
status = "Inactive"
}
format = "Csv"
deliveryInfo = {
destination = {
resourceId = azurerm_storage_account.test.id
container = azurerm_storage_container.test.name
rootFolderPath = "test"
}
},
definition = {
type = "Usage"
timeframe = "Custom"
timePeriod = {
from = "2024-08-01T00:00:00Z"
to = "2024-08-09T00:00:00Z"
}
dataSet = {
granularity = "Daily"
}
}
}
}
}
|
Indeed it works fine when run locally. The error occurs when I run a pipeline in Azure DevOps to deploy these resources. |
Would you please get the terraform logs from the pipeline? Here's how:
|
Hi @ms-henglu, |
@ms-henglu |
Hi @BeeDeeBePope , thanks! You could share it by github gist, or if you want to make it more private, you could upload it to a private github repo and add me as a reader. |
Hi @ms-henglu, sorry for the delay. I have created the repository and sent an invitation |
Thanks @BeeDeeBePope for the logs! I've opened this PR to fix it: #616 |
Hi @ms-henglu. Thank you for your work! How can I verify if that works on my end? Is there already a release I can check? |
I'm deploying a solution that uses Subscription scoped Cost Management Exports using Azure DevOps.
I'm using azapi 1.14.0 to create the exports with a Custom timeframe(azurerm does not support it at the moment). When running locally
terraform apply
works fine, but in automation, it fails with the following error for each subscription:The
azapi_resource
definition:Provider definitions:
Other resources successfully provision with azurerm so I assume the service connection is configured correctly. Also tried creating scheduled subscription exports with azurerm, so the Service Principal should have the correct access permissions.
Am I missing some configuration?
Why is it trying to access the trafficmanager.net endpoint?
https://costmanagement.trafficmanager.net/subscriptions//providers/Microsoft.CostManagement/exports/usageExport
The text was updated successfully, but these errors were encountered: