Skip to content

Instantly share code, notes, and snippets.

@Jaykul
Last active April 8, 2018 02:28
Show Gist options
  • Save Jaykul/7861a9f9ee5a846fcdbe2e4638928389 to your computer and use it in GitHub Desktop.
Save Jaykul/7861a9f9ee5a846fcdbe2e4638928389 to your computer and use it in GitHub Desktop.
Silly Azure Portal

I've been working with Azure runbooks and I ocassionally actually dump the default scripts that are generated from the portal and run them. This last time, I spent a little time cleaning it up to keep around.

I'll probably share the completed thing later, but I wanted to post this correction right away because it's pretty confusing.

There's an internal private function in the generated Deploy.ps1 which looks like this, but really should just be a one-liner like this:

"microsoft.compute", "microsoft.network" | Register-AzureRmResourceProvider -ProviderNamespace { $_ }
# See these two bits, the function, and the call to the function (which is slightly further down the default script):
Function RegisterRP {
Param(
[string]$ResourceProviderNamespace
)
Write-Host "Registering resource provider '$ResourceProviderNamespace'";
Register-AzureRmResourceProvider -ProviderNamespace $ResourceProviderNamespace;
}
# Register RPs
$resourceProviders = @("microsoft.compute", "microsoft.network");
if ($resourceProviders.length) {
Write-Host "Registering resource providers"
foreach ($resourceProvider in $resourceProviders) {
RegisterRP($resourceProvider);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment