base64 -i SPN-certificate.pfx -o SPN-certificate.txt
openssl pkcs12 -in SPN-certificate.pfx -out SPN-certificate.pem -nodes -password pass:'password'
In some cases, the pfx file may not be accepted by Terraform due to this issue.
The solution is to re-create the pfx file. Run the following commands respectively.
openssl pkcs12 -in pfx-cert-name.pfx -out key-file-name.key -nodes -password pass:'password' -nocerts
openssl pkcs12 -in pfx-cert-name.pfx -out crt-file-name.crt -nodes -password pass:'password' -nokeys
openssl pkcs12 -export -out "pfx-cert-name.pfx" -inkey "key-file-name.key" -in "crt-file-name.crt" -macalg sha1 -certpbe PBE-SHA1-3DES -keypbe PBE-SHA1-3DES -password pass:'password'
az login --service-principal --username $ARM_CLIENT_ID --tenant $ARM_TENANT_ID --password ./SPN-certificate.pem
terraform init \
-backend-config='resource_group_name=${{ secrets.RESOURCE_GROUP_NAME }}' \
-backend-config='storage_account_name=${{ secrets.STORAGE_ACCOUNT_NAME }}' \
-backend-config='container_name=${{ secrets.STORAGE_CONTAINER_NAME }}' \
-backend-config='key=${{ vars.ENV_NAME }}.terraform.tfstate'
terraform {
backend "azurerm" {}
}
terraform import azurerm_key_vault_access_policy.policy1 "/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.KeyVault/vaults/xxx/objectId/xxx"
terraform state rm azurerm_key_vault_access_policy.policy1
https://www.garyjackson.dev/posts/azure-function-app-conflicting-plans/
az account set --subscription "subscriptionId"
az storage blob list --account-name storage_account_name --container-name container_name
az storage blob delete --account-name storage_account_name --container-name container_name --name "blob_file_name"
az storage blob lease break --account-name storage_account_name --container-name container_name --blob-name "blob_file_name"