8

Every tutorial and resource I've seen has you create a SendGrid account through the GUI, but I want to be able to use the cli. Is it possible?

Something like:

az sendgrid create
user3052659
  • 161
  • 1
  • 5
  • Hey. Did you find a way to programmatically create a send grid account. The documentation is not good. – RuSs Feb 20 '18 at 23:03

3 Answers3

8

Although you cannot create a SendGrid account using Azure Cli, you can create one using an ARM template, as following

{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "name": {
        "type": "string"
    },
    "location": {
        "type": "string"
    },
    "plan_name": {
        "type": "string"
    },
    "plan_publisher": {
        "type": "string"
    },
    "plan_product": {
        "type": "string"
    },
    "plan_promotion_code": {
        "type": "string"
    },
    "password": {
        "type": "secureString"
    },
    "email": {
        "type": "string"
    },
    "firstName": {
        "type": "string"
    },
    "lastName": {
        "type": "string"
    },
    "company": {
        "type": "string"
    },
    "website": {
        "type": "string"
    },
    "acceptMarketingEmails": {
        "type": "string"
    }
},
"resources": [
    {
        "apiVersion": "2015-01-01",
        "name": "[parameters('name')]",
        "type": "Sendgrid.Email/accounts",
        "location": "[parameters('location')]",
        "plan": {
            "name": "[parameters('plan_name')]",
            "publisher": "[parameters('plan_publisher')]",
            "product": "[parameters('plan_product')]",
            "promotionCode": "[parameters('plan_promotion_code')]"
        },
        "properties": {
            "password": "[parameters('password')]",
            "acceptMarketingEmails": "[parameters('acceptMarketingEmails')]",
            "email": "[parameters('email')]",
            "firstName": "[parameters('firstName')]",
            "lastName": "[parameters('lastName')]",
            "company": "[parameters('company')]",
            "website": "[parameters('website')]"
        }
    }
]

Then you can use az group deployment create to provision your template.

Loul G.
  • 997
  • 13
  • 27
  • For reference this is not current possible with the CLI as it will fail because the marketplace legal terms haven't been accepted which as far as I can tell you can't do via CLI :-( Doable with PowerShell but that's a pain if you have to mix CLI and PowerShell in a deployment script – Simon Aug 24 '19 at 14:03
  • @Simon Legal terms can be accepted using `az vm image accept-terms --publisher Sendgrid --offer sendgrid_azure --plan free` – Loul G. Sep 03 '19 at 09:21
  • Thanks, I had tried a few variations of that but couldn't get it to work, much appreciated – Simon Sep 03 '19 at 14:49
  • I get this error message when trying to deploy the ARM template through Terraform: "Legal terms have not been accepted for this item on this subscription" – Costin_T May 07 '20 at 11:08
  • @Simon when you say that you cannot get it to work, what's exactly the issue ? – Loul G. Sep 13 '20 at 15:25
  • I can't seem to find the documentation for this resource type... Can anyone assist? it isn't where I'd expect it to be: https://learn.microsoft.com/en-us/azure/templates/ – Karl Merecido Nov 06 '20 at 13:17
  • I guess the schema is the documentation? https://github.com/Azure/azure-resource-manager-schemas/blob/master/schemas/2015-01-01/Sendgrid.Email.json – Karl Merecido Nov 06 '20 at 13:37
  • I did agree to the terms, but I get the following error: `The subscription is not registered to use namespace 'Sendgrid.Email'`. I checked my subscription's resource providers, but it's not listed :-( – Ramon de Klein May 30 '22 at 08:53
1

but I want to be able to use the cli. Is it possible?

As far as I know, azure doe not support create sendgrid via CLI at this time.

C:\Users>az --help

For version info, use 'az --version'

Group
    az

Subgroups:
    account   : Manage subscriptions.
    acs       : Manage Azure Container Services.
    ad        : Synchronize on-premises directories and manage Azure Active Directory resources.
    appservice: Manage your Azure Web apps and App Service plans.
    batch     : Manage Azure Batch.
    cloud     : Manage the registered Azure clouds.
    component : Manage and update Azure CLI 2.0 (Preview) components.
    container : Set up automated builds and deployments for multi-container Docker applications.
    disk      : Manage Azure Managed Disks.
    documentdb: Manage your Azure DocumentDB (NoSQL) database accounts.
    feature   : Manage resource provider features, such as previews.
    group     : Manage resource groups and template deployments.
    image     : Manage custom Virtual Machine Images.
    iot       : Connect, monitor, and control millions of IoT assets.
    keyvault  : Safeguard and maintain control of keys, secrets, and certificates.
    lock      : Manage Azure locks.
    network   : Manages Azure Network resources.
    policy    : Manage resource policies.
    provider  : Manage resource providers.
    redis     : Access to a secure, dedicated cache for your Azure applications.
    resource  : Manage Azure resources.
    role      : Use role assignments to manage access to your Azure resources.
    snapshot  : Manage point-in-time copies of managed disks, native blobs, or other snapshots.
    sql       : Manage Azure SQL Databases and Data Warehouses.
    storage   : Durable, highly available, and massively scalable cloud storage.
    tag       : Manage resource tags.
    vm        : Provision Linux or Windows virtual machines in seconds.
    vmss      : Create highly available, auto-scalable Linux or Windows virtual machines.

Commands:
    configure : Configure Azure CLI 2.0 Preview or view your configuration. The command is
                interactive, so just type `az configure` and respond to the prompts.
    feedback  : Loving or hating the CLI?  Let us know!
    find      : Find Azure CLI commands based on a given query.
    login     : Log in to access Azure subscriptions.
    logout    : Log out to remove access to Azure subscriptions.
Jason Ye
  • 13,710
  • 2
  • 16
  • 25
1

No, it's not possible.

Here you can see all available commands: https://learn.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest

Jim Aho
  • 9,932
  • 15
  • 56
  • 87