Microsoft documentation for az cosmosdb collection create
says that --partition-key-path can be used to name a key to use for a collection. In this case, it's a "MongoDB" collection:
name='myName'
databaseName='myDatabase'
resourceGroupName='myRg'
collectionName='myCollection'
echo "Create database account"
az cosmosdb create --name $name --kind MongoDB --locations "Central US"=0 --resource-group $resourceGroupName
echo "Create database"
az cosmosdb database create --name $name --db-name $databaseName --resource-group $resourceGroupName
echo "Create collection $collectionName"
az cosmosdb collection create --name $name --db-name $databaseName --resource-group $resourceGroupName --collection-name $collectionName --partition-key-path '/partition'
What do I need to change to avoid the following error and create a partitioned collection?
Create database account
...
Create database
...
Create collection myCollection
ERROR: Operation Failed: Invalid Arg {"Errors":["The partition key component definition path
'C:\/Apps\/Git\/partition' could not be accepted, failed near position '0'. Partition key paths must contain only
valid characters and not contain a trailing slash or wildcard character."]}
So after all the back and forth it appears to be a path escaping issue, where the partition key, when provided with single quotes, was assumed to be a folder from bash.
However changing single quotes to double quotes worked.
When tried to run with cmd /C the following seems to be working.
cmd "/C az cosmosdb collection create --name $name --db-name $databaseName --resource-group $resourceGroupName --collection-name $collectionName --partition-key-path "/partition""
Related
I am setting up users in Airflow installation using -
airflow create_user -r Viewer -u wsmith -f Will -l Smith -p xxxx -e xxxxx#gmail.com
Now if I want to change the role from Viewer to Admin- how would do I do that ?
Is my only option to do it via the UI ? Could I update the database tables directly ?
You can do this via backend database tables.
Within the airflow schema:
select * from AB_ROLE;
--- This will list all the available roles that you have
update AB_USER_ROLE
set ROLE_ID = <desired role from above>
where
USER_ID in (select ID from AB_USER where USERNAME = <USERID>);
--- Update to desired role.
You can delete the user and create back with new role and same credentials
airflow delete_user
airflow create_user -r <new_role> -u <old_username> -p <password> -f Firstname -l Lastname -e email#domain.com
I am trying to use Flyway to set up a DB2 test/demo environment in a Docker container. I have an image of DB2 running in a docker container and now am trying to get flyway to create the database environment. I can connect to the DB2 docker container and create DB2 objects and load them with data, but am looking for a way for non-technical users to do this (i.e. clone a GitHub repo and issue a single docker run command).
The Flyway Docker site (https://github.com/flyway/flyway-docker) indicates that it supports the following volumes:
| Volume | Description |
|-------------------|--------------------------------------------------------|
| `/flyway/conf` | Directory containing a flyway.conf |
| `/flyway/drivers` | Directory containing the JDBC driver for your database |
| `/flyway/sql` | The SQL files that you want Flyway to use |
I created the conf, drivers, and sql directories. In the conf directory, I placed the file flyway.conf that contained my flyway Url, user name, and password:
flyway.url=jdbc:db2://localhost:50000/apidemo
flyway.user=DB2INST1
flyway.passord=mY%tEst%pAsSwOrD
In the drivers directory, I added the DB2 JDBC Type 4 drivers (e.g. db2jcc4.jar, db2jcc_license_cisuz.jar),
And in the sql directory I put in a simple table creation statement (file name: V1__make_temp_table.sql):
CREATE TABLE EDS.REFT_TEMP_DIM (
TEMP_ID INTEGER NOT NULL )
, TEMP_CD CHAR (8)
, TEMP_NM VARCHAR (255)
)
DATA CAPTURE NONE
COMPRESS NO;
Attempting to perform the docker run with the flyway/flyway image as described in the GitHub Readme.md, it is not recognizing the flyway.conf file, since it does not know the url, user, and password.
docker run --rm -v sql:/flyway/sql -v conf:/flyway/conf -v drivers:/flyway/drivers flyway/flyway migrate
Flyway Community Edition 6.5.5 by Redgate
ERROR: Unable to connect to the database. Configure the url, user and password!
I then put the url, user, and password inline and It could not find the JDBC driver.
docker run --rm -v sql:/flyway/sql -v drivers:/flyway/drivers flyway/flyway -url=jdbc:db2://localhost:50000/apidemo -user=DB2INST1 -password=mY%tEst%pAsSwOrD migrate
ERROR: Unable to instantiate JDBC driver: com.ibm.db2.jcc.DB2Driver => Check whether the jar file is present
Caused by: Unable to instantiate class com.ibm.db2.jcc.DB2Driver : com.ibm.db2.jcc.DB2Driver
Caused by: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver
Therefore, I believe it is the way that I am setting up the local file system or associating to local files with the flyway volumes that is causing the issue. Does anyone have an idea of what I am doing wrong?
You need to supply absolute paths to your volumes for docker to mount them.
Changing the relative paths to absolute paths fixed the volume mount issue.
docker run --rm \
-v /Users/steve/github-ibm/flyway-db-migration/sql:/flyway/sql \
-v /Users/steve/github-ibm/flyway-db-migration/conf:/flyway/conf \
-v /Users/steve/github-ibm/flyway-db-migration/drivers:/flyway/drivers \
flyway/flyway migrate
I am developing a set of Scripts for Azure and I would like to know how to populate a CosmosDB collection with az.
Currently, I know how to create a Database and Collection but how to initialize the Database?
az cosmosdb create \
--resource-group $RESOURCE_GROUP \
--name $COSMOS_DB_ACCOUNT
az cosmosdb database create \
--resource-group-name $RESOURCE_GROUP \
--name $COSMOS_DB_ACCOUNT \
--db-name $COSMOS_DB_NAME
az cosmosdb collection create \
--resource-group-name $RESOURCE_GROUP \
--name $COSMOS_DB_ACCOUNT \
--collection-name $COSMOS_DB_COLLECTION_NAME \
--db-name $COSMOS_DB_NAME \
--partition-key-path $COSMOS_DB_COLLECTION_PARTITION_KEY
Reading the documentation, I didnĀ“t see a solution.
az doesn't provide any data-movement options for Cosmos DB.
For the SQL API, you'll either need to create your own command-line tool, or use the Cosmos DB-supplied Data Migration Tool (Windows-only, unlike az), which provides a command-line interface. For example:
dt /s:JsonFile /s.Files:.\inputdata.json /t:DocumentDBBulk /t.ConnectionString:"AccountEndpoint=<name>;AccountKey=<key>;Database=<db>;" /t.Collection:<collname> /t.CollectionThroughput:<throughput>
This has support for the MongoDB API as well, but you can also use native command-line tools such as mongoimport.
I want to use delegates with DOCKER CONTENT TRUST. I generated the delegate.crt/key on the collaborator's machine and now I am trying to rotate the snapshot key with:
notary key rotate localhost:5000/ubuntu snapshot -r
=> Error: unknown shorthand flag: 'r' in -r
Usage:
notary key rotate [ GUN ] [flags]
Why am I getting this error?
Had "unknown shorthand flag: 'r' in -rm" error but due bad argument, not that I wanted delegation.
Was:
$ docker run -rm busybox echo hello world
Causing:
unknown shorthand flag: 'r' in -rm
The correct parameter is --rm two dashes.
$ docker run --rm busybox echo hello world
the --rm flag that can be passed to docker run which automatically
deletes the container once it's exited from.
Source: https://github.com/prakhar1989/docker-curriculum#11-docker-run
(Disclaimer: I know zilch about Docker Notary, so this might be completely bogus)
According to the Notary documentation:
The root and targets key must be locally managed - to rotate either
the root or targets key, for instance in case of compromise, use the
notary key rotate command without the -r flag. The timestamp key must
be remotely managed - to rotate the timestamp key use the notary key
rotate timestamp -r command.
So I'd guess you're trying to use a non-locally managed root or targets key which apparently is not supported.
I have created new session database using the command (aspnet_regsql.exe -S -E -ssadd -sstype p) and it created DB called ASPState. Then I renamed it to something like E_ASPStateDB. I have configured the correct DB name in the sessionState connection string. But still it throws the exception Invalid object name 'ASPState.dbo.ASPStateTempApplications'
What i need to do, so that it will use the new database name?
I ran this on the db server that the site was connecting to and it solved it immediately.
USE [ASPState]
GO
DECLARE #return_value int
EXEC #return_value = [dbo].[CreateTempTables]
SELECT 'Return Value' = #return_value
GO
Since you renamed the DB you will have to regenerate the ASPnet session tables. Below is the solution to it.
To Remove, use following command: [open visual studion command prompt]
aspnet_regsql -ssremove -S [SERVER] -U [USER] -P [PWD] -d [DATABASE] -sstype c
Then add them again by following command
aspnet_regsql -ssadd -S [SERVER] -U [USER] -P [PWD] -d [DATABASE] -sstype c
You must modify the stored procedures because they invoke the tables with the database name and schema, as follows:
[ASPState].dbo.ASPStateTempApplications
you have to change it for
[E_ASPStateDB].dbo.ASPStateTempApplications
once you have registered a DB name using aspnet_regsql, you shall have to use the name you registered with. There is no point really to change the name afterwards. If you really want to use a name like E_ASPStateDB, why not delete the registration of ASPState first and then re-registering with the name E_ASPStateDB. It shall make your life easier