mattmcspirit / azurestack

Azure Stack Resources
80 stars 41 forks source link

Request for export of used variables. #73

Closed ghost closed 5 years ago

ghost commented 5 years ago

Is it possible to write out an export of all variables that are used during the deployment. I'm now writing a script to clean up the installation for redeploy of the ASDK. Now i have to extract the information from the log file and it could be handy if there is a (hash)file I can import for that information.

mattmcspirit commented 5 years ago

What specifically do you need in order to clean up a deployment?

ghost commented 5 years ago

$ConfigASDKLog = Get-ChildItem -Path C:\ConfigASDK\Logs\ -Filter ConfigASDKLog. -Recurse $ConfigASDKLog = Get-Content -Path $ConfigASDKLog.FullName $asdkregEntry = $ConfigASDKLog -match '\"ResourceName"\: \"asdkreg' | Select-Object -First 1 $asdkregEntry -match '.+\"(.+)\",' $asdkreg = $Matches[1] $asdkreg

Import the registration module that was downloaded with the GitHub tools

Import-Module C:\AzureStack-Tools-master\Registration\RegisterWithAzure.psm1

Provide Azure subscription admin credentials

Add-AzureRmAccount -Credential $AzureADCredentail

Unregister Azure Stack

Remove-AzsRegistration -PrivilegedEndpointCredential $CloudAdminCred -PrivilegedEndpoint AzS-ERCS01 -RegistrationName $asdkreg

This is what i now do because i didn't had the "asdkreg" reg name. But it maybe would be handy for all generated key's to be exported.

mattmcspirit commented 5 years ago

Ok. Would you need the AAD cred, perhaps just the regUserName and sub Id? I could create a separate text file or CSV and then deposit it inside the Completed folder when the run is finished. It would just contain AAD User, RegSubID and the registration info (rg, name etc) but you’d still have to write a script like that above to grab the info.

Also, for the above, you can be more specific with the query by using asdkreg-$computerName* ( see actual configasdk.ps1 for specifics)

Is the registration the only thing you’re looking to clean up?

mattmcspirit commented 5 years ago

OK, so in 1811.2, the script will now create 2 PS1 files and store them in the Completed folder, for that particular deployment. The PS1 files will clean up registration, and the App Service Azure AD app respectively. The PS1 files will be automatically generated by the script itself, and will be populated with information pertinent to that deployment, but not sensitive password information.

All the user would need to do, ahead of redeploying, is run both of those scripts, enter passwords when prompted, and the scripts should take care of the cleanup.

I don't know how to clean up the rest of the ASDK Azure AD integration - an ASDK Azure AD deployment creates a good number of Azure AD apps, none of which have a common ID that i can see, but if you find something, let me know, and I'll figure something out.

Closing for now, and will re-open if 1811.2 doesn't fit the bill...