So basically I have fetched out all the resources from azure portal through powershell , now I want to save it into tfvars file using the script. Can anybody enlighten what file management methods can I use here in order to get all the resources inside a tfvars file.
Related
I have CSV file uploaded to Azure blob storage and I would like to get the content of it using PowerShell script so I can use the values. I am using Azure function and was thinking about using Get-AzStorageBlobContent. However, I do not want to download the file to my local machine and can't see how I might be able to utilize the command.
I was planning on using Get-Content to get the content of the file out so I can use the values further along the script.
We are building a temp review app in terraform. Currently when review app is finished with the resources are destroyed with terraform using terraform apply -destroy. What i need to do is also remove the terraform state file for this infrastructure from the azure container. Could I use terraform -destroy to also remove the state file and how can i do this?
One of the workaround you can follow,
When we are using terraform destroy that time our resource detailed also removed from terraform.tfstate by removing from portal itself.
So to remove any particular resource from .tfstate you can try something like below;
First would suggest you to after destroy the file list the state file you have then remove those.
This below command is used to get the available instances which are in state file.
terraform state list
After listing those try with below which will remove from .tfstate file as mentioned by #Ansuman Bal i have also tried and it works fine .
terraform state rm "azurerm_resource_group.example"
OUTPUT DETAILS FOR REFERENCE:-
NOTE:- This aforementioned cmdlts will remove the instance/resources from .tfstate file only not from portal. Only terraform destroy can do that.
For more information please refer this SO THREAD| Terraform - Removing a resource from local state file.
I'm using the Google Credentials locally and I refer it by selecting the actual json file path "GOOGLE_APPLICATION_CREDENTIALS" with WebApi, I couldn't find nothing to save the file so I just copied the whole information and put as a string inside of the Application settings on azure, but it didn't worked! How can I do this ?
If your json file is in the project path, you can modify the csproj file to include your xxx.json file when publishing. Or manually add the json file in kudu. The path is as follows:
D:\home\site\wwwroot\xxx.json
Then set the environment variable in Application settings on portal as below:
Thanks for joey cai's answer, you can refer the origin post.
Where to store the JSON file which will be referenced for the environment variable in asp.net hosted on Azure
I am using Azure batch Service and I am able to add applications,pools and tasks to the same .I have attached a resource file to each task.I am confused about how to access the resource file or inputs provided to the task in the application that I have uploaded to the Azure batch .Please help me in the same
If you have attached the ResourceFile(s) to the individual tasks then the file(s) should be uploaded to the filePath you specified(if any) appended to the environment variable in your task of AZ_BATCH_TASK_WORKING_DIR (https://learn.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).
For an ad-hoc experience you can download https://azure.github.io/BatchExplorer/ and navigate to an existing node and/or task to see a file explorer for how the directories in the node are layed out.
I want to create a new provider for terraform. It is suppose to read the state files produced by Azure provider and create an Ansible inventory file out of it. I am using this guide as a base https://www.terraform.io/docs/extend/writing-custom-providers.html
These are my solutions until now:
Reading the states JSON files with go.
using depends_on = ["Azure.example"] in my Ansible provider and get access to variables how it is done here https://stackoverflow.com/a/45492093/4244999
How can I read the state files into a provider as variables with terraform functions?