Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. param(
  2. $DockerUserName = "",
  3. $DockerPassword = "",
  4. $ShareUserName = "",
  5. $SharePassword = "",
  6. $ServicePrincipalName = "",
  7. $ServicePrincipalPassword = ""
  8. )
  9.  
  10. $azurePassword = ConvertTo-SecureString $ServicePrincipalPassword -AsPlainText -Force
  11. $psCred = New-Object System.Management.Automation.PSCredential($ServicePrincipalName , $azurePassword)
  12.  
  13. $storagePassword = ConvertTo-SecureString $SharePassword -AsPlainText -Force
  14. $storageCred = New-Object System.Management.Automation.PSCredential($ShareUserName , $storagePassword)
  15.  
  16. $registryPassword = ConvertTo-SecureString $DockerPassword -AsPlainText -Force
  17. $registryCred = New-Object System.Management.Automation.PSCredential($DockerUserName , $registryPassword)
  18.  
  19. Connect-AzAccount -ServicePrincipal -Credential $psCred -Force -TenantId myTenant.onmicrosoft.com
  20.  
  21. Start-Sleep 2
  22.  
  23. $Module = Import-Module Az -PassThru -ErrorAction SilentlyContinue
  24. if ($null -eq $Module)
  25. {
  26. Install-Module Az -Scope CurrentUser -Force
  27. }
  28.  
  29. $Container = Get-AzContainerGroup -Name "container-name" -ResourceGroupName 'resource-group' -ErrorAction SilentlyContinue
  30. if ($null -ne $Container)
  31. {
  32. Remove-AzContainerGroup -InputObject $Container
  33. }
  34.  
  35. $Params = @{
  36. ResourceGroupName = "resource-group"
  37. Name = "container-name"
  38. Cpu = 1
  39. MemoryInGB = 1.5
  40. Port = @(8080, 10001)
  41. DnsNameLabel = "container-name"
  42. OsType = 'Linux'
  43. Image = "adamdriscoll/myImage:1.0.1"
  44. AzureFileVolumeShareName ="my-storage"
  45. AzureFileVolumeAccountCredential = $storageCred
  46. AzureFileVolumeMountPath = "/home/config"
  47. EnvironmentVariable = @{
  48. ENVVAR = "Hello!"
  49. }
  50. RegistryCredential = $registryCred
  51. RegistryServerDomain = "index.docker.io"
  52. }
  53.  
  54. New-AzContainerGroup @params
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement