@Aravind R Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
Sometimes this error may occur due to security policy, try to run the below cmdlets You could run set-executionpolicy remotesigned
or Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
as administrator and let me know the status.
This error suggests that the cmdlets "New-AzStorageContext" and "Get-AzStorageBlob" are not available on the system where Terraform is running.
To use these cmdlets, you need to have the "Az.Storage" PowerShell module installed. You can install this module by running the following command in PowerShell:
Install-Module -Name Az.Storage -AllowClobber
Once the module is installed, you can import it in your Terraform provisioner using the Import-Module
cmdlet. For example, you can add the following code to import the module before using the cmdlets:
provisioner "powershell" {
inline = [
"Import-Module Az.Storage",
"New-AzStorageContext -ConnectionString 'your_storage_account_connection_string'",
"Get-AzStorageBlob -Context $ctx -Container 'your_container_name' -Blob 'your_blob_name'"
]
}
Make sure to replace the "your_storage_account_connection_string", "your_container_name", and "your_blob_name" placeholders with the appropriate values for your scenario.
Install Terraform on Windows with Azure PowerShell
The New-AzStorageContext cmdlet creates an Azure Storage context. The default Authentication of a Storage Context is OAuth (Azure AD), if only input Storage account name. See details of authentication of the Storage Service in https://learn.microsoft.com/rest/api/storageservices/authorization-for-the-azure-storage-services.
Please let us know if you have any further queries. I’m happy to assist you further.
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.